Reputation: 7129
Using jQuery is it possible to append another value to $(this) in order to refer for example to a child element? What I need is something like this:
$(this + " div").remove(".cover");
But the syntax + " div"
doesn't work, is there a way to do this using jQuery?
Upvotes: 1
Views: 39
Reputation: 20260
You need to provide this
as the context in which to look for the div
, eg:
$('div', this).remove('.cover');
Which is equivelant to $(this).find('div').remove('.cover')
Internally, selector context is implemented with the
.find()
method, so$( "span", this )
is equivalent to$( this ).find( "span" )
.
Upvotes: 2
Reputation: 103368
You're trying to find children div
elements of this element, and therefore you can use:
$(this).find("div").remove(".cover");
Upvotes: 3