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;
}
精彩评论