Srdjan Srdjan - 23 days ago 7
Javascript Question

Placing logo with Javascript

I have used following code to place logo on my site wpbarbers . com.
Everything works fine in Mozilla and Chrome but Internet Explorer and Safari are not showing logo.

Thanks for tip!

(function() {
var logoHere, logoMain, text;
text = document.querySelector(".header .header-inner .logo a");
console.log(text);
text.innerHTML = "";
logoHere = document.querySelector(".header .header-inner .logo a");
logoMain = document.createElement("img");
logoMain.setAttribute("src", "http://wpbarbers.com/wp-content/uploads/2016/11/wp-barbers-logo.png");
logoMain.setAttribute("height", "143");
logoMain.setAttribute("width", "300");
logoMain.setAttribute("alt", "WP Barbers");
logoHere.append(logoMain);
}).call(this);

Answer

Use appendChild not append. append is experimental and not what you are looking for in this case.

logoHere.appendChild(logoMain);
Comments