Javascript $("#someDiv").attr("scrollHeight") 在 jquery-1.6.1 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6194837/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
$("#someDiv").attr("scrollHeight") not working in jquery-1.6.1
提问by adentum
$("#someDiv").attr("scrollHeight")works in jquery 1.3.2for all browsers. But on updating to jquery 1.6.1, it only works in IE9.
Firefox 4.0.1, Google Chrome 11 and Safari 5 all return undefined.
$("#someDiv").get(0).scrollHeighthowever still works for all browsers.
$("#someDiv").attr("scrollHeight")适用于所有浏览器的jquery 1.3.2。但是在更新到 jquery 1.6.1 时,它只适用于 IE9。Firefox 4.0.1、Google Chrome 11 和 Safari 5 都返回 undefined。
$("#someDiv").get(0).scrollHeight但是仍然适用于所有浏览器。
Anybody knows what is going on?, is attr("scrollHeight")broken in the newest jquery (i.e version 1.6.1)?
有人知道发生了什么吗?attr("scrollHeight")在最新的jquery(即1.6.1版)中被破坏了吗?
回答by Lightness Races in Orbit
jQuery 1.6 introduced .propand changed the meaning of .attr.
jQuery 1.6 引入.prop并改变了.attr.
(Always worth checking the documentation first; the page for .attrtalks about this too.)
(总是值得先检查文档;讨论这个的页面.attr也是如此。)

