HTML:
<p class="acont"><a >我是一匹来自北方的狼</a></p>
CSS:
p.acont a{float:left; font-size:12px;} /*注意此处没有定义margin-right*/
JQUERY:
alert($(".acont a").css("margin-right")); //返回“0px”
疑问:
.acont a在CSS中并没有定义“margin-right”属性,为什么jquery会返回0px呢?
我的目的:
在jquery中判断.acont a是否定义了“margin-right”属性,如果有的话,其值不变,如果没有的话,指定一个“margin-right”属性的值。
有劳了。
可能我没有表达明白,用下面的表格表达可能更明白些。
应该可以看出,判断CSS中是否定义跟0px还是有区别的。