为什么摘要和详细标签不起作用?

问题描述 投票:0回答:3

我在这里尝试过这段代码。

<details>
<summary>
标签未在我尝试使用的任何浏览器中显示。为什么?

<details>
  <summary>StudentResult</summary>
  <p> The student result are just average...</p>
</details>

html html-tag-details
3个回答
4
投票
mozila firefox 和 Internet Explorer 不支持

<details>
<summary>
标签。 此外,它们仅受高于 12 的任何版本的 google chrome 支持。因此,这取决于您使用的浏览器和版本。

以下链接将有所帮助:摘要标签详情标签


2
投票

尝试一下:

<html>
<head>
<script src="//code.jquery.com/jquery-1.11.0.js" type="text/javascript" />
<script type="text/javascript">
$(function(){
$('#showNow').click(function(){
$('details').slideDown();
});
});
</script>
</head>
<body>
<button id='showNow'>Show</button>
     <details style='display:none;'>
      <summary>StudentResult</summary>
      <p> The student result are just average...</p>
     </details> 

    </body>
    </html>

1
投票

如果您希望内容默认可见,则需要指定 open 属性。

<details open="open">
    <summary>StudentResult</summary>
    <p> The student result are just average...</p>
</details>

请记住,并非所有浏览器都有此功能的本机实现,因此如果您希望它在所有浏览器中都同样工作,您可能需要使用一些 JavaScript 来增强它。

© www.soinside.com 2019 - 2024. All rights reserved.