Reputation: 3732
In javascript I have set up a listener to a drop down in the DOM. When my handler fires, i have to remove siblings of the event target. $(#sometagname).siblings().remove() works, but i won't always know the tag name. I would rather just get my parent object and call .sibling()remove(). event.target.parentNode.siblings().remove() doesn't work.
When I print out $(#sometagname) in an alert popup, I get [object Object]. When I print event.target.parentNode in an alert box, I get [object HTMLCellElement]. How can I get the [object Object] through some kind of getParent call? thanks
Upvotes: 0
Views: 1141
Reputation: 160833
In the event handler, you can use this:
$(this).parent().siblings().remove();
Or: $(event.target).parent().siblings().remove();
Or: $(event.target.parentNode).siblings().remove();
Upvotes: 1