cosmo cosmo - 4 months ago 22
Javascript Question

"document.getElementById(div).style.display = none" not working

I'm trying to hide three divs when I click a button, but my js isn't working.

function display() {
document.getElementById("Contentable").style.display = none;
document.getElementById("savebtn").style.display = none;
document.getElementById("stylebar").style.display = none;
}


When I click the button there is an uncaught reference error that says "none" is not defined.

Answer

The none should be in " " and you can use JQuery for this as well.

function display() {
    $("#Contentable").hide();
    $("#savebtn").hide();
    $("#stylebar").hide();
   }