JavaScript window resize event

前端 未结 13 1048
余生分开走
余生分开走 2020-11-22 00:58

How can I hook into a browser window resize event?

There\'s a jQuery way of listening for resize events but I would prefer not to bring it into my project for just t

13条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 01:02

    You can use following approach which is ok for small projects

    
    

    function yourHandler(e) {
      console.log('Resized:', e.target.innerWidth)
    }
    
      Content... (resize browser to see)
    

提交回复
热议问题