HTML:jQuery的CSS方法
<div id="that" style="margin-left: 10px; border-width: 2px"></div>
的jQuery:
// alerts "10px 0px" which is strange, isn't it?
alert($('#that').css('margin-left') + ' ' + $('#that').css('border-width'));
的jsfiddle:http://jsfiddle.net/vZpAv/
为什么jQuery的那样做的?它不应该得到2px?首先,我认为这是因为CSS属性中的破折号(因为css('borderWidth')
正常工作),但正如您所看到的,它对margin-left
确实很好。
可能重复HTTP ://stackoverflow.com/questions/5904380/jquery-css-borderwidth) –