Javascript on window resize end

前端 未结 3 515
谎友^
谎友^ 2021-01-12 03:05

I am calling a function when the window is resized like this:

window.addEventListener(\"resize\", calculateDimensions());

But I need a way

3条回答
  •  天命终不由人
    2021-01-12 03:25

    Use window.addEventListener("resize", calculateDimensions);

    calculateDimensions() means that you execute the function and then use that result as a callback function.

提交回复
热议问题