Bind to ready and resize at same time using jQuery .on()

后端 未结 3 1059
粉色の甜心
粉色の甜心 2021-01-05 08:02

This works for running the same code on both ready and resize:

$(document).ready(function() {

    $(window).resize(function() {

         // Stuff in here h         


        
3条回答
  •  一整个雨季
    2021-01-05 08:16

    Bind it both the load and resize event as below:

    $(window).on('load resize', function () {
    // your code
    });
    

    Much simpler - hope this helps.

提交回复
热议问题