Reputation: 67
so. I've used a prototype that will create a div element (var $mainDiv) with several other elements inside, when this is called i get a small widget box. this div element is nested inside a div called wrapper (id wrapper).
later on i created this function:
$dismissButton.click(function() {
$("#wrapper").remove($mainDiv);
});
because when i click the dismiss button (nested inside the div and part of the widget box) i want it to make the entire box disappear.
it's not working.
what am i doing wrong? (also tried .empty()
)
Upvotes: 0
Views: 123
Reputation: 781934
If you want to remove $mainDiv
, it should be:
$mainDiv.remove();
.remove()
removes the elements that the method is applied to. If you use an argument, it should be a selector that filters the set of elements. E.g.
something.remove(selector);
is equivalent to:
something.filter(selector).remove();
In your case, since $mainDiv
is not one of the elements in $("#wrapper")
, it didn't remove anything.
Upvotes: 0