jquery implements dynamic changes to div width and height

  • 2020-06-12 08:24:25
  • OfStack

Complete code:


<!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>
<title>jquery The dynamic change div Width and height </title>
<script type="text/javascript" src="jquery/jquery-1.11.2.min.js"></script>
</head>
<body>
<div>
<input id="addwidthkeleyi" value=" Increase the width " type="button" />
<input id="reducewidthkeleyi" value=" Reduce the width of the " type="button" />
<input id="addheightkeleyi" value=" Increase the height " type="button" />
<input id="reduceheightkeleyi" value=" Reduce the height " type="button" />
  Click the button and notice the bottom div Changes in width and height </div>
<div style="border:1px solid #999;width:200px;height:200px" id="keleyidiv"></div>
<script type="text/javascript">
$("#addwidthke"+"leyi").on("click", function () {
$("#keleyidiv").width($("#keley" + "idiv").width() + 50);
});
$("#reducewidthk" + "eleyi").on("click", function () {
$("#keleyidiv").width($("#kel"+"eyidiv").width() - 50);
});
$("#addheightkele" + "yi").on("click", function () {
$("#kel" + "eyidiv").height($("#keleyidiv").height() + 50);
});
$("#reduceheightkeley" + "i").on("click", function () {
$("#keleyidiv").height($("#keleyidiv").height() - 50);
});
</script>
</body>
</html>

This is the end of this article, I hope you enjoy it.


Related articles: