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