<分区>
据我所知,DOM 元素 style
的 CSS 属性是驼峰式的,这样 min-height
就是 element.style.minHeight
,但在我下面的示例中,样式属性为空,但 jQuery 的抽象正确地获取了它。
// element with css: #test{ min-height: 100px; }
var el = document.getElementById('test');
console.log( el.style.minHeight );
// ""
console.log( $(el).css('min-height') );
// "100px"
See fiddle for this in action .
jQuery 做了什么来提取我没有做的正确样式属性?
有趣的是,直接在html元素上添加样式属性does work .