javascript - remove parent tag <strong> from child tag <a> -
this question has answer here:
i want in javascript remove <strong>
tag function: myfunc(this)
<strong><a href="#" onclick="myfunc(this)">mylink</a></strong>
i want clean code, <strong>
tag needed removed
this should that:
function myfunc(node) { node.parentnode.parentnode.replacechild(node, node.parentnode); }
the problem can run once, need additional check:
function myfunc(node) { var parent = node.parentnode; if (parent.nodename === 'strong') { parent.parentnode.replacechild(node, parent); } }
Comments
Post a Comment