Я застрял, почему селектор .not() не влияет на проверку. Это мой HTML форма:jQuery Selector .not() не работает
<input name="Title" id="Title" type="text" />
<div id="ErrorTitle" class="hiddenbox"></div>
<input name="Text" id="Text" type="text" />
<div id="ErrorText" class="hiddenbox"></div>
<input name="Price" id="Price" type="text" />
<div id="ErrorPrice" class="hiddenbox"></div>
И этот JQuery:
if($('#Title').val() == '')
{
$('#Title').focus();
ErrorBox('Please enter title', 'ErrorTitle'); // Write message in .hiddenbox
$('.hiddenbox').not('#ErrorTitle .hiddenbox').hide();
}
else if($('#Text').val() == '')
{
$('#Text').focus();
ErrorBox('Please enter text', 'ErrorText'); // Write message in .hiddenbox
$('.hiddenbox').not('#ErrorText .hiddenbox').hide();
}
else if($('#Price').val() == '')
{
$('#Price').focus();
ErrorBox('Please enter price', 'ErrorPrice'); // Write message in .hiddenbox
$('.hiddenbox').not('#ErrorPrice .hiddenbox').hide();
}
При подаче формы никакого сообщения одна ошибки не будет отображаться! Не ошибаюсь ли я ?!
Как вы используете селектор идентификатора просто использовать 'нет («# ErrorTitle»)' нет необходимости выбора класса – Satpal
Узнайте, как использовать самые основные 'CSS' селекторы перед началом коды , Пространство обозначает иерархию. – melancia