+ 3

Can I add image in animation attrubute

17th Jun 2017, 4:04 PM
Rahul Kumar
Rahul Kumar - avatar
2 Answers
+ 1
maybe with some js??? $(document).on("click","#addPic", function(e){ //div element having attr display:none; $("#Pic").animate({height:"toggle"},500, function(){ $(this).append("<img>").data({src:"sourceOfImg", alt:"altTextForImg"}); }); what this will do is if you have a hidden div on the webpage <div id="Pic" style="height:500px; display:none;"></div> and a button to activate it or something <input type="button" id="addPic" value="Add Pic"> the onclick event will be triggered. the animation which will take 500ms will toggle the height of the div (0 -> 500px) and once the animation is finished the function will be called which will add an image as a child element to the div. hope this was what you were looking for!!
18th Jun 2017, 5:26 AM
Michael Szczepanski
Michael Szczepanski - avatar
21st Jul 2020, 3:10 AM
shubham kumar
shubham kumar - avatar