3
我有几个<div>
标签具有不同的类名称。 当页面加载时,我想要删除并在某个<div>
中添加另一个类,但不知如何,它无法按预期工作。RemoveClass AddClass当页面加载
HTML
<div class="redBG">
<div class="yellowIcon"></div>
</div>
<div class="greenBG">
<div class="yellowIcon"></div>
</div>
CSS
.redBG{
background-color:red;
width: 300px;
height:30px;
z-index: 1;
}
.yellowIcon{
background-color:yellow;
width: 20px;
height:20px;
cursor: pointer;
z-index:20;
}
.greenBG{background-color:green}
.black{background-color:black}
JS
$('div, .redBG').load(
function()
{
$(this).removeClass('.redBG').addClass('.black');
}
);
哦,非常感谢Darren!它运作良好。 – 2015-02-17 20:59:44