当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jquery动态改变div宽度和高度

jquery动态改变div宽度和高度

2019年03月31日  | 移动技术网IT编程  | 我要评论
代码如下:


<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "https://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>jquery动态改变p宽度和高度</title>
<script type="text/javascript" src="https://keleyi.com/keleyi/pmedia/jquery/jquery-1.11.2.min.js"></script>
</head>
<body>
<p>
<input id="addwidthkeleyi" value="增加宽度" type="button" />
<input id="reducewidthkeleyi" value="减少宽度" type="button" />
<input id="addheightkeleyi" value="增加高度" type="button" />
<input id="reduceheightkeleyi" value="减少高度" type="button" />
 点击按钮,注意下方p宽高的变化</p>
<p style="border:1px solid #999;width:200px;height:200px" id="keleyip"></p>
<script type="text/javascript">
$("#addwidthke"+"leyi").on("click", function () {
$("#keleyip").width($("#keley" + "ip").width() + 50);
});
$("#reducewidthk" + "eleyi").on("click", function () {
$("#keleyip").width($("#kel"+"eyip").width() - 50);
});
$("#addheightkele" + "yi").on("click", function () {
$("#kel" + "eyip").height($("#keleyip").height() + 50);
});
$("#reduceheightkeley" + "i").on("click", function () {
$("#keleyip").height($("#keleyip").height() - 50);
});
</script>
</body>
</html>

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网