Question

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!

Was it helpful?

Solution

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

e.g

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

OTHER TIPS

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);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top