我有如下所示的内容。
<div class="alert alert-info" style="width:224px">
<strong>Info!</strong> This is a netural alert
</div>
通过javascript或jquery,在特定条件下,我想将该div元素的类从alert alert-info
更改为alert alert-success
。那可能吗?如果是这样,怎么办?
根据条件更改类别,请使用以下示例
$('.alert').click(function(){
if(0==0)//your condition goes here
{
$(this).removeClass('alert-info').addClass('alert-success');
}else{
$(this).removeClass('alert-success').addClass('alert-info');
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句