enter code hereI am having a little problem with jquery.empty().
I have some Html Divs which look like below:
<div id="Description_Error" class="ui-helper-hidden errorMessage"></div>
<div id="Order_Error" class="ui-helper-hidden errorMessage"></div>
<div id="ColorHex_Error" class="ui-helper-hidden errorMessage"></div>
These Divs get filled up at run time with some Uls and Lis. They are basically used to show the errors. Now I am wiping out all the errors that it was showing before I do a POST.
I use
$(‘ui-helper-hidden errorMessage’).empty();
for that. Now, i fit is showing all three errors then it will wipe out two bue leave one. If it is showing only one error at the time then it will not be removed at all. I am not sure why class selection decides to leave one element behind all the times. Anyway, i tried to replicate the same behavior on Jsfiddler but it works fine. I am not able to find a clue on what might be wrong on my code. Any suggestions?
here is the fiddler link which works all file. Just my HTMl code does not work fine:
You are neither refering to a class nore an element identifier.
To reference classes use the
.and to use element identifiers use#.In your case this will empty all the divs:
DEMO – Empty all element which have both classes
I also added some element which only have one or the other class in the DEMO to show that they are not effected.