开发者

jQuery get outerWidth() of #foo

开发者 https://www.devze.com 2023-02-25 15:43 出处:网络
Hi really quick question, how do I get the outerWidth() of an element #foo with jQuery? One catch is that this is neste开发者_JAVA技巧d within a function for $(\"a.preview\") but I need to get the wi

Hi really quick question, how do I get the outerWidth() of an element #foo with jQuery?

One catch is that this is neste开发者_JAVA技巧d within a function for $("a.preview") but I need to get the width of the ID and NOT the class #preview

    while ((left + 400) > window.innerWidth){
        left -= 400 + #preview.outerWidth();
        }


Since jQuery 1.8 the only way to get outerWidth is to add the boolean parameter to the function call. outerWidth() no longer works as a getter of the outerwidth. Now, since jQuery 1.8, it returns the DOM object itself (s. http://blog.jquery.com/2012/08/16/jquery-1-8-box-sizing-width-csswidth-and-outerwidth/).

Now you have to call:

$('#preview').outerWidth(addMargin)

with parameter addMargin

false (means without adding margin to the outerwidth)

or

true (with margin adding to outerwidth)


Try this:

jQuery("#preview").outerWidth()


try this:

while ((left + 400) > window.innerWidth){
     left -= 400 + $('#preview')[0].outerWidth;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号