[英]What is the equivalent of .height() and .width() of jQuery in pure JavaScript?
[英]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.