[英]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.