效果体验:http://keleyi.com/keleyi/phtml/jquery/23.htm

 

完整代码:

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <title>jquery动态改变div宽度和高度-柯乐义</title>
 5 <script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery/jquery-1.11.2.min.js"></script>
 6 </head>
 7 <body>
 8 <div>
 9 <input id="addwidthkeleyi" value="增加宽度" type="button" />
10 <input id="reducewidthkeleyi" value="减少宽度" type="button" />
11 <input id="addheightkeleyi" value="增加高度" type="button" />
12 <input id="reduceheightkeleyi" value="减少高度" type="button" />
13 <a href="http://keleyi.com/a/bjad/tar6g4m7.htm" target="_blank">原文</a> <a href="http://keleyi.com/">首页</a> <a href="http://keleyi.com/keleyi/phtml/">特效库</a> 点击按钮,注意下方div宽高的变化</div>
14 <div style="border:1px solid #999;width:200px;height:200px" id="keleyidiv"></div>
15 <script type="text/javascript">
16 $("#addwidthke"+"leyi").on("click", function () {
17 $("#keleyidiv").width($("#keley" + "idiv").width() + 50);
18 });
19 $("#reducewidthk" + "eleyi").on("click", function () {
20 $("#keleyidiv").width($("#kel"+"eyidiv").width() - 50);
21 });
22 $("#addheightkele" + "yi").on("click", function () {
23 $("#kel" + "eyidiv").height($("#keleyidiv").height() + 50);
24 });
25 $("#reduceheightkeley" + "i").on("click", function () {
26 $("#keleyidiv").height($("#keleyidiv").height() - 50);
27 });
28 </script>
29 </body>
30 </html>

 

参考:

http://keleyi.com/a/bjac/e753bc9c582e4fb0.htm

http://keleyi.com/a/bjad/yy8jnwqj.htm

 

web前端资源:

http://www.cnblogs.com/jihua/p/webfront.html

posted on 2015-02-09 14:33  计划  阅读(105300)  评论(0编辑  收藏  举报