質問

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