views:

15

answers:

1

Hi,

I'm doing some form error handling/manipulation and I have the need to remove an error div that is before the input that is being validated...

HTML:

I'd like to remove the div.textError if the input field is validated. I tried this...

$(this).before('<div class="textError"></div>').remove('<div class="textError"></div>');

and no dice. any help would be greatly appreciated

+1  A: 

The before method adds something. To get a relative use the prev method. So something like this:

$(this)
  .prev('div.textError')
  .remove()
  .end()
.before('<div class="textError"></div>');
g.d.d.c