-5

I added this Javascript code to add some html to my footer (Want to have "Follow us on" on the left side of the Facebook icon) -

document.getElementById("footer").innerHTML = "Follow Us";

For some reason it completely removed the footer. Not sure what I'm doing wrong. Code seems ok. Footer before adding code Footer after adding code

Any idea what is going wrong? (Want to use Javascript to add this HTML)

java11
  • 43
  • 1
  • 5

1 Answers1

0

The problem is you're swaping the html inside the footer content to the string Follow Us. You have two options:

Option 1 in Javascript:

document.getElementById("footer").innerHTML += "Follow Us";

Option 2 in Jquery:

$('#footer').append('Follow Us');

Check if you're using the correct object ID too.