[jQuery] How to programmatically ad a div element and animate it
Hi,
Im new to Jquery and have been trying to dynamically create a new div
element with document.createElement.
I can successfully insert this element into the dom but I want to
animate it on creation. After inserting the element into the DOM i try
and access it using a JQuery selector but it does not seem to find it.
Example code.
function CreateNewElement()
{
var container = $("#contentContainer");
var myDiv = (document.createElement('div'))
myDiv.setAttribute("id", "div1");
myDiv.innerHtml = "test content";
container.appendChild(myDiv);
$("div1").toggle("slow");
}
Any help greatly appreciated.
Many Thanks
Ham
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home