本文實例講述了jQuery設定指定網頁元素寬度和高度的方法。分享給大家供大家參考。具體實作方法如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <!DOCTYPE html>
<html>
<head>
<script src= "js/jquery.min.js" >
</script>
<script>
$(document).ready( function (){
$( "button" ).click( function (){
$( "#div1" ).width(500).height(500);
});
});
</script>
</head>
<body>
<div id= "div1" style= "height:100px;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:lightblue;" >
</div>
<br>
<button>Resize div</button>
</body>
</html>
|
登入後複製
希望本文所述對大家的jQuery程式設計有所幫助。