javascript - Replace innerHTML in plain JS -


i want remove except img-element footer container:

<footer>     <p>some text</p>     <img src="logo.jpg"> </footer> 

in jquery this:

var logo = $('footer img'); $('footer').html(logo); 

how do in plain js?

without recreating original element, if want

var footer = document.getelementsbytagname('footer')[0]; var img = footer.getelementsbytagname('img')[0]; footer.innerhtml = ''; footer.appendchild(img) 

demo: fiddle


Comments