jQuery位置和尺寸操作的方法
<body>
<style>
*{
margin: 0;
padding: 0;
}
.father{
width: 200px;
height: 200px;
background-color:indianred;
border: 50px solid;
position: relative;
}
.son{
width: 100px;
height: 100px;
background-color: cornflowerblue;
position: absolute;
left: 50px;
top: 50px;
}
</style>
<script src="js/1.12.4.js"></script>
<script>
$(function () {
var btns = document.getElementsByTagName("button");
btns[0].onclick = function () {
console.log($(".father").width());
}
btns[1].onclick = function () {
$(".father").width("500px");
}
})
</script>
<div class="father">
<div class="son"></div>
</div>
<button>获取</button>
<button>设置</button>
</body>