为了账号安全,请及时绑定邮箱和手机立即绑定

jquery实时监听div高度变化

jquery实时监听div高度变化

皈依舞 2018-10-18 14:26:15
$(".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>


查看完整回答
反对 回复 2018-11-05
  • 1 回答
  • 0 关注
  • 5941 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号