I'm creating dynamically divs using javascript. I want to assign the style to none.
style="display: none;"
According to this question, I can to do this with the following options
publishcontent.style.display="none";
publishcontent.setAttribute("style", "display: none;");
But this isn't working. This is the way I created the divs. No way of the options I found is working. If I edit the html with firebug and type style="display: none;" it works.
This is a demo showing the example.
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);
arrayNames.length > 0your jsbin is showing arrayNames.length is 1. So this condition will not be true.