I am trying to remove a dynamically created element using jQuery.
Here is my example: http://jsfiddle.net/4uxbu/
When you click submit it highlights the required fields and displays the text This field is required. after the input. When the user clicks on the input the red box goes away, I want the text below the input to go away as well.
The message is set using the following code:
$('#' + required[i]).after('<p style="font-weight:bold;" id="' + required[i] + '_error">' + emptyerror + '</p>');
and I've tried to remove it with:
$('p#' + required[i] + '_error').remove();
But I can't get it to work properly.
Required is as below
required = ["vidHeight", "title", "vidWidth", "vidLen", "thumb", "file"];
Please see the fiddle for the full code.
Thanks
$('form p.error').remove()? Simple, clean, elegant.