سؤال

i am trying to get the new browser width after resizing. i have tried all..bind, live, resize, now setTimeout. i am not good at jquery but i can understand some. i hoped someone here might give a hand. this is my code

function myfunction() {

         var w = ($(".wrap").innerWidth());
         var m = ($(".module").outerWidth(true));
         var total = parseInt(w/m);
         var newwrap = total * m;


         $(".wrap").css("width",newwrap);

 }; myfunction(jQuery)



$(document).ready(function(){
   setTimeout("myfunction()",100)
});

i want to make the function run every time the width is changed, after resizing browser. or get the new width after resizing.

thank you in advanced!

هل كانت مفيدة؟

المحلول

try this function you wrote, to be called on onresize event of the body.

e.g

<body onresize="myFunction();">
<!-- your content -->
</body>

نصائح أخرى

i am not sure what you want but this may help

width = 0;
function myfunction() {
  //your code to calculate width  or use $(window).width();
  width = 100;
}
$(document).ready(function(){
   $(window).resize(myfunction);
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top