<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>练习</title>
<script type="text/javascript" src="js/jquery-1.4.js" ></script>
<style type="text/css">
.test_div{ width:400px; height:200px; background:#CCCCCC; }
.blod{ font-weight:bold;}
.red{ color:red;}
.hidden{ display:none;}
</style>
</head>
<body>
<div id="test_div" class="test_div">
这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.这是一个测试的demo.
</div>
<input type="button" id="test_btn" value="显示/隐藏" />
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
$("#test_btn").toggle(function(){
$("#test_div").addClass("hidden");
},function(){
$("#test_div").removeClass("hidden");
});
});
</script>
jquery toggle
最新推荐文章于 2022-04-20 22:32:29 发布