How to find an element relative to script’s position? For instance, in the case below I would like getSelfParent to return the $('button') element
<button>
<script>
getSelfParent().click(function(){...});
</script>
</button>
$(this).parent() did not work.
EDIT:
I want to avoid:
- adding ID’s anywhere
- traversing whole tree every time I am looking for the
selfelement
Try to generate HTML|SCRIPT output as: