问题是,jQuery正在检测页面上存在的任何错误消息。将CSS样式应用于包含错误消息的div
**看到的例子here
- 和我不想要的时候没有消息应用的样式。
代码:
$(document).ready(function() {
if($('.CP_CF_Container > span.msg-error').length){
$('.vertical-input').addClass('checkbox-fld-error')
}
});
CSS:
.checkbox-fld-error{border:1px solid red}
.CP_CF_Container{width:50%;background-color:#eee;padding:5px;}
.msg-error{color:red}
HTML:
<div class="CP_CF_Container">
<div class="vertical-input">hello there</div>
<span class="msg-error" >Error</span>
</div>
<br>
<div class="CP_CF_Container">
<div class="vertical-input">hello there</div>
<span class="msg-error" >Error</span>
</div>
<br>
<div class="CP_CF_Container">
<div class="vertical-input">hello there</div>
</div>
太谢谢你了! – namretiolnave