javascript - How to add an image inside a dynamically created div? -


i creating dynamic div inside javascript following code:

 var div = $('<div id="a1"></div>').html("<font color=green>this demo</font>");  

i want add image above text inside dynamically created div not getting how achieve it.

i creating dynamic divs using loop , want add images @ same time in it.

for(var i=0; i<size; i++)     {         //alert("title zeroth manual is: "+result.manuals[i].title);         var div = $('<div id="a1"></div>').html("<font color=green>this demo..</font>");          $('#a1').prepend("<img src='iphone.png' />");         $('#data').append(div);     } 

how can it? please help.

i tried , working fine me.

var elem = document.createelement("img");        elem.setattribute("src", "http://img.zohostatic.com/discussions/v1/images/defaultphoto.png");        elem.setattribute("height", "30");        elem.setattribute("width", "30");        document.getelementbyid("maindiv").appendchild(elem);


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -