jQuery get outerWidth() of #foo
jQuery get outerWidth() of #foo
嗨,真的很快的问题,我如何得到一个元素#foo与jQuery的outerWidth()
?
一个问题是,这是嵌套在$("a.preview")
的函数中,但我需要得到ID的宽度,而不是类 #preview
while ((left + 400) > window.innerWidth){
left -= 400 + #preview.outerWidth();
}
由于jQuery 1.8唯一的方法来获得outerWidth是添加布尔参数的函数调用。outerWidth()不再作为outerWidth的getter。现在,从jQuery 1.8开始,它返回DOM对象本身(s. http://blog.jquery.com/2012/08/16/jquery-1-8-box-sizing-width-csswidth-and-outerwidth/)。
现在你必须调用:
$('#preview').outerWidth(addMargin)
带addMargin参数
false (means without adding margin to the outerwidth)
或
true (with margin adding to outerwidth)
试试这个:
jQuery("#preview").outerWidth()
try this:
while ((left + 400) > window.innerWidth){
left -= 400 + $('#preview')[0].outerWidth;
}
相关文章:
- HighChart : Usage of setData
- if(foo!==null)的计算结果为true,即使foo为null
- 渲染<选项值=“;foo”;选择>在服务器上
- 代码挑战:创建一个跟踪对象实例总数的类Foo
- Difference between methods of defining JavaScript 'class
- 为什么“foo()”在这里有效
- 为什么我在下面的..of循环中得到意外令牌
- Appending the innerhtml of <th>
- Animation cuts off multiple lines of text in <p>
- javascript: functionname() instread of functionname()
- jQuery使用.of()删除事件处理程序时出现的问题
- Three.js issue creating meshes outside of loader's load(
- jquery in the middle of html
- JavaScript equivalent of C#'s DynamicObject?
- nodejs console.log of object
- value of jquery sortable
- Javascript imageData returns array of 0's
- 为什么for.of不记录foo值
- inner text of element passed as <span onclick=foo(this) &
- jQuery get outerWidth() of #foo