首页 > 编程 > JavaScript > 正文

jQuery div层的放大与缩小简单实现代码

2019-11-20 22:53:49
字体:
来源:转载
供稿:网友
复制代码 代码如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.content
{
border: 1px solid #ccc;
width: 440px;
overflow: hidden;
margin: 10px;
}
</style>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if ($('#content').height() > 400)
$('#content').height(400);
$('#bigger').toggle(function() {
$('#content').height($('#content').height() + 100);
$('#bigger').html('缩小');
}, function() {
$('#content').height($('#content').height() - 100);
$('#bigger').html('放大');
})
});
</script>
</head>
<body>
<div id="content" class="content">
容1<br />
容2<br />
容3<br />
容4<br />
容5<br />
容6<br />
容7<br />
容8<br />
容9<br />
容10<br />
容11<br />
容12<br />
容13<br />
容14<br />
容15<br />
容16<br />
容17<br />
容18<br />
容19<br />
容20<br />
容21<br />
容22<br />
容23<br />
容24<br />
容25<br />
</div>
<br />
<span id="bigger">放大</span>
</body>
</html>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表