문제

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