Add Image Tag using Jquery

#Add Image Tag using Jquery::

var img = $('<img id="dynamic">'); 
var imgurl = STORES_THE_IMAGE_PATH

//Equivalent: $(document.createElement('img'))

img.attr('src', imgurl);

img.appendTo('#imagediv');

# Using JQuery we can also add a <img> tag in a container

var img = $('<img />', { 

  id: 'Myid',

  src: 'MySrc.gif',

  alt: 'MyAlt'

});

# Add image to the container Box
img.appendTo($('#Your_Div_ID'));

var myImage = $('<img/>');

myImage.attr('width', 300);

myImage.attr('height', 300);

myImage.attr('class', "YOUR_CUSTOM_CLASS");

myImage.attr('src', photo_Url);

Leave a Reply

Your email address will not be published. Required fields are marked *