Reputation: 964
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);
Upvotes: 1
Views: 2779
Reputation: 230
you can simply hide using jquery hide function.
$("#"+ name).hide();
Upvotes: 0
Reputation: 224
"name" variable stores the id of publishcontent so use it in jquery
$('#'+name).css('display','none');
Upvotes: 5