super simple for you folks.
Was playing around w/this code.
why can’t i get the newDiv text & class to show? I declared a variable div, appended it to the content div, It shows that there is a new div, but no class or text is added to it.
$(document).ready(function(){
$("#content").append("<h1> page 1 </h1>").addClass( "content" );
var newDiv = "<div>";
$("#content").append(newDiv);
$(newDiv).addClass( "sCt1" ).append("<p>here is text....</p>");
});
Have you tried adding the class and appending the paragraph tag before appending the new div to content? It looks like the query selector for newdiv might lose it’s reference point to that div specifically after being appended.
Makes sense thank you for the explanation.
got this so far
$(document).ready(function(){
$("#content").append("<h1> page 1 </h1>").addClass( "content" );
var $newdivs;
for (i = 0; i < 5; i++) {
$newdivs = $('<div class="subSect" />').text(i);
$('#content').append($newdivs);
}
//but not sure am on the right track w/this bit.
var $countClass;
for (j = 0; j < 5; j++) {
$("subSect").attr("class", "subSect"+[j]);
}
});