joexn joexn - 5 months ago 16
HTML Question

Use custom tag using JavaScript only

On my site, as a little footer I guess, I use the tag

<joexn id="yo">

and the javascript

var div = document.getElementById('yo');
div.insertAdjacentHTML( 'beforeBegin', 'joexn.com' );


This produces a watermark/footer and want I want to know is how can I change it so the tag is just
<joexn>
using Javascript only. I want minimalist code only and no clutter. I tried using
document.getElementByTagName('joexn');
but that didn't work.

What's the easiest method?

Answer

try using document.querySelector(): DEMO

var div = document.querySelector('joexn');
div.insertAdjacentHTML( 'beforeBegin', 'joexn.com' );