If I have:
$activity = $("#activity_contents").html();
is there a way to exclude a list item with a class:
<li class="correct">Something</li>
from the html content in the #activity_contents div displaying?
Thanks.
Update
I have a drag and drop activity where the reset button resets the activity to it's original state using:
<a href="#" id="reset_activity" class="activity_button" title="Clear my answers" >Reset</a>
jQuery
$activity = $("#activity_contents").html();
$("#activity #reset_activity").click(function(e) {
e.preventDefault();
$("#activity_contents").html($activity);
refreshActivity();
});
But I don't want any ul li with a class of correct to reset. Is that even possible?
Thanks
Use find() to find particular 'li' with class and setting its display property to 'none'.It just hiding that li. If you want to delete that li then use
html code
One approach would be to clone the element, find and remove the
.correct
descendant element(s), then reset the query using.end()
and retrieve the cloned HTML:You could also do this without cloning the elements, however that would affect the element that currently exists in the DOM. The above method wouldn't removing anything from the DOM whereas the one below would:
However, based on your update, you could simply just remove the elements directly. There is no need to use the
.html()
method: