tdh1985
10-09-2005, 06:31 PM
HI,
I'm wanting to add an image to a DIV tag when the user clicks a button, I have managed to create some text this way and was wondering if the same technique could be used to add an image?
Thanks.
{
newelement=document.createElement("p");
// this sets the new elements id to newpara
newelement.setAttribute("id","newpara");
//creates a textnode with some text in it
newtext=document.createTextNode("The new text");
newelement.appendChild(newtext);
document.body.appendChild(newelement);
}
I'm wanting to add an image to a DIV tag when the user clicks a button, I have managed to create some text this way and was wondering if the same technique could be used to add an image?
Thanks.
{
newelement=document.createElement("p");
// this sets the new elements id to newpara
newelement.setAttribute("id","newpara");
//creates a textnode with some text in it
newtext=document.createTextNode("The new text");
newelement.appendChild(newtext);
document.body.appendChild(newelement);
}