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) –