toggle在连续单击时,触发事件发生
<h2>什么是JQuery</h2>
<div id="content" hidden="true">jQuery的是跨平台的 JavaScript库旨在简化客户端脚本的HTML。
[3]它是免费的开源软件,使用许可的麻省理工学院许可证。
[2] Web分析表明,它是广泛部署的JavaScript库。</div>
</div>
事件:
$("h2").toggle(function(){
$(this).next().hide();
},function(){
$(this).next().show();
});
或者:
$("h2").toggle(function(){
$(this).next().toggle();
},function(){
$(this).next().toggle();
});
效果:
第一次单击:
第二次单击: