簡體   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