Delete quotes:
var catdiv = document.getElementById("divsId");
becomes
var catdiv = document.getElementById(divsId);
You do not have an element with the id "divsId".
In a completely unrelated note, you cannot be sure that catdiv.style.display will always be "" when it is visible. There are other styles that make it appear (for example, "inline", "block").
A better solution might be:
function togglesDiv(divsId){ var catdiv = document.getElementById("divsId"); if(catdiv.style.display === "none"){ catdiv.style.display = ""; } else { catdiv.style.display = "none"; } }
(And yes, I really wanted to put the triple equal === in)
source share