繁体   English   中英

Javascript 等效于.width() 和.height()

[英]Javascript equivalent for .width() and .height()

以下 jquery 代码的 javascript 等效项是什么

  $(document).on({
    mousemove: function(event) {
        widget = $('.widget').last();
        x = event.pageX;
        y = event.pageY;

        widget.width(x); // here is the real problem
        widget.height(y); // here is the real problem
      }
    },
  });

试试这个:

widget = $('.widget').last()[0];
x = event.pageX;
y = event.pageY;

widget.style.width  = `${x}px`;
widget.style.height = `${y}px`;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM