Javascript эквивалент для .width () и .height () - PullRequest
0 голосов
/ 30 мая 2020

Что эквивалентно javascript для следующего jquery кода

  $(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
      }
    },
  });

1 Ответ

0 голосов
/ 30 мая 2020

Попробуйте это:

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

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