不确定我有以下CSS一个div容器:ATTR( '高度')jQuery中
#container {
position:relative;
overflow:hidden;
width:200px;
height:200px;
}
为什么会这样:
alert('height is ' + $("#container").attr('height'));
回到那个高度是不确定的?
谢谢。
不确定我有以下CSS一个div容器:ATTR( '高度')jQuery中
#container {
position:relative;
overflow:hidden;
width:200px;
height:200px;
}
为什么会这样:
alert('height is ' + $("#container").attr('height'));
回到那个高度是不确定的?
谢谢。
尝试:
$("#container").height()
这是由于在CSS的高度是和HTML标记不是实际属性。
jQuery.attr
引用HTML属性而不是CSS属性。使用.css("height")
或提到的.height()
方法。
更多关于这些方法: