导读:jquery 标题点击高亮内容显示,点击不高亮内容隐藏 。
<html>
<head>
<title>jQuery</title>
<style>
.ccc{ background:red;}
</style>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script>
$(function(){
$(".one h2.two").toggle(function(){
$(this).addClass("ccc");
$(this).next().show();
},function(){
$(this).removeClass('ccc');
$(this).next().hide();
})
});
</script>
</head>
<body>
<div class="one">
<h2 class="two">标题</h2>
<div class="three">
sdafdsafadsfdasfdasfasfasfasfasfasfasfsafasfdasfa
</div>
</div>
</body>
</html>