Generated output is as follows:
HTML
<div id="resultCancel" class="error" style="display: block;">
<a class="close">X</a>
<ul style="">
<li for="ProductId" generated="true" class="error" style="">Please Enter License Key</li>
</ul>
</div>
I need to empty the contents of the li when you click the a.close (before anyone kills me, we’re using an old code base which is why I’m using the .live funciton)
$('a.close').live('click',function(){
$(this).parent().fadeOut("fast");
$(this).closest//.next//.sibling('ul').addClass('foo');
});
by using closest I can go up the DOM tree, I need to go down. .next and .sibling are having no effect…. If it matters the div#resultCancel is triggered by jQuery validation plug in.
You can use
.next()Use
.on()instead of.live()as the latter is deprecated..Also you need
not change the textas you arehiding the parent div.Check Fiddle
For Dynamic elements delegate the event