我在这里尝试过这段代码。
<details>
和 <summary>
标签未在我尝试使用的任何浏览器中显示。为什么?
<details>
<summary>StudentResult</summary>
<p> The student result are just average...</p>
</details>
尝试一下:
<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>
如果您希望内容默认可见,则需要指定 open 属性。
<details open="open">
<summary>StudentResult</summary>
<p> The student result are just average...</p>
</details>
请记住,并非所有浏览器都有此功能的本机实现,因此如果您希望它在所有浏览器中都同样工作,您可能需要使用一些 JavaScript 来增强它。