$(".btn1").click(function(){$("#box").animate({height:"300px"}); });我想实时的监听$("#box")的高度,请问该如何操作呢?
1 回答

素胚勾勒不出你
TA贡献1827条经验 获得超9个赞
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="jquery.min.js"></script>
<style>
#box{
height: 100px;
width: 100px;
background: red;
}
</style>
</head>
<body>
<div id="box"></div>
<button class="btn1">dianwo</button>
<script>
$(".btn1").click(function(){
$("#box").animate({height:"300px"}, {step: function(){console.log($(this).height())}}).resize(function() {
console.log($(this).height());
});
});
</script>
</body>
</html>
添加回答
举报
0/150
提交
取消