So I have some html that looks like the following:
<div class='something unknown' id='something_unknown_1'>
<button onClick='removeParent(self)'>Remove me and my parent div</div>
</div>
<div class='something unknown' id='something_unknown_2'>
<button onClick='removeParent(self)'>Remove me and my parent div</div>
</div>
…and so on. How exactly would I reference the button that fired the onClick without knowing the id of the button? I would like to eventually have my removeParent(self) method look like:
buttonThatWasClicked.parent().remove();
I would add a class to the buttons so the function does not get bound to every button on the page only the ones you would like it to.
Then use the jquery class selector to bind a function that removes the parent.
Demo: http://jsfiddle.net/cXLqK/