I am dynamically creating divs using JavaScript and want to set their style to none.
style="display: none;"
After reading a question on Stack Overflow, I tried the following options:
publishcontent.style.display="none";
publishcontent.setAttribute("style", "display: none;");
Unfortunately, neither of these methods seem to be working for me. Despite trying various approaches, nothing is hiding the divs as expected. Interestingly, manually adding style="display: none;" through Firebug does work.
You can view a live demo to see the issue in action.
publishpaging=document.createElement("div");
var name="df"+counterName;
publishpaging.id=name;
counterName=counterName+1;
arrayNames.push(name);
counter++;
publishcontent=document.createElement("div");//"<div class='bonecardSmall'></div>";
publishcontent.className = "bonecardSmallP";
publishcontent.id=index.id;
if(arrayNames.length > 1){
//publishpaging.style.display="none";
publishpaging.setAttribute("style", "display: none;");
}
publishpaging.appendChild(publishcontent);