Проблема в том, что jQuery обнаруживает любое сообщение об ошибке, присутствующее на странице. /> -и я не хочу, чтобы стиль применялся, когда нет сообщения. < /p>
код: < /p>
$( document ).ready(function() {
if($('.CP_CF_Container > span.msg-error').length){
$('.vertical-input').addClass('checkbox-fld-error')
}
});
< /code>
css: < /p>
.checkbox-fld-error{border:1px solid red}
.CP_CF_Container{width:50%;background-color:#eee;padding:5px;}
.msg-error{color:red}
< /code>
html: < /p>
hello there
Error
hello there
Error
hello there
Подробнее здесь: https://stackoverflow.com/questions/223 ... or-message