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);     } } 

demo


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -