jQuery類中添加多個屬性 jQuer為元素添加類 HTML code 可以看到jQuery類中添加多個屬性渲染效果是以內嵌樣式出現的。 而jQuer為元素添加的類沒有內嵌樣式的優先順序高 可以看到渲染效果中沒有funny的 background color: gray ; 和 color: yel ...
jQuery類中添加多個屬性
$('#five .a')
.css({
color:'blue',
border:'2px solid green',
background:'blue'
});
jQuer為元素添加類
$('#five .a')
.addClass('funny');
HTML code
<style>
.funny{
font-size: 21px;
background-color: gray ;
padding: 10px;
color: yellow ;
}
</style>
<div id="five">
<div class="a">A</div>
</div>