javascript - How to hide and show things in jQuery based on the existence of other elements? -



javascript - How to hide and show things in jQuery based on the existence of other elements? -

i have form jquery validation plugin generate div tags class "error" if there validation error on form submission. if such divs exist want display additional error message above form. message stored so:

<p class="toperror">oops errors found!</p> <form id="myform"> // blah blah </form>

if error divs weren't generated plugin, like:

if (('#myform div.error').length() > 0 ) { $('p.toperror').show(); }

in situation how can solve , need top error vanish moment there isn't error divs in form.

if ($('#myform div.error').length > 0 ) { $('p.toperror').show(); } else { $('p.toperror').hide(); }

javascript jquery

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -