How to create img tag in jQuery and set it as only content of some div?
If target div has some content, replace it and put dynamically created img tag.
Here is What I have tried:
$(".someClass").click(function(){
var $img = $('<img allowfullscreen ></img>', {
'width': 650,
'height': 580,
'src': $(this).find('img').attr('data')
});
$('#someId').html($img);
});
Thanks.
1 Answer