I have a href like this
<a title="my title text" id="6" href="#" class="someclass" onclick="deleteRows(this.parentNode.parentNode)">X</a>
Now I want to add a new exactly the same href but I have no idea how to add onclick with ‘this’ paraeter.
Tried those 2 but non of it is working.
var a = document.createElement('a'); // create DIV element
a.onclick = function() {
(a.parentNode.parentNode);
};
and
var a = document.createElement('a'); // create DIV element
a.onclick = function() {
(this.parentNode.parentNode);
};
Searched google but did not faound anything.
How I should do it?
You forgot to call
deleteRowsinside your event listener: