I'm trying to insert a DOM element using jQuery but it keeps being inserted as text instead.
var newImg = "<h1>Hi</h1>";
$("li").each(function myFn(){
this.addEventListener("mouseover", function myFn2 () {
this.before(newImg);
})
});
$('li').on('mouseover', function () { ... });would perform the same function