Hmmm
All the answers I’ve seen here suggest that this should work, but…
Is…
var qnDivName = "qnDiv" + i;
var currentQnDiv = document.createElement("div");
var qnDivId = document.createAttribute("id");
qnDivId.nodeValue = qnDivName;
currentQnDiv.setAttributeNode(qnDivId);
currentQnDiv.className = "questionContainer";
equivalent to…
var currentQnDiv = $("<div/>", {
"class": "questionContainer",
id: "qnDiv" + i
});
alert("qndiv class: " + currentQnDiv.className);
?
The alert gives ‘undefined’.
The ‘i’ is from a for loop. I’m dynamically creating divs to attach to a document further down the page…
testDiv.appendChild(currentQnDiv);
} //end for loop
the ordinary js works, but the jQuery doesn’t. I have other jQuery that works in a calling function, so…
Any ideas?
Use
Your
currentQnDivobject is a jQuery collection, not a basic Dom object.