展开、收起div的jQuery代码

时间:2021-09-15 19:35:49
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>
<a href="javascript:;" id="toggle" target="_self">展开 代码中的:; 请自行更改成英文的冒号和分号再运行</a>
<div id="content" style="display: none;"><p>隐藏内容 www.daimabiji.com.com<p><p>隐藏内容<p></div>
<script type="text/javascript" src="http://www.daimabiji.com/statics/js/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#toggle").click(function() {
$(this).text($("#content").is(":hidden") ? "收起" : "展开");
$("#content").slideToggle();
});
});
</script>
</body>
</html>