javascript - Display img element without having to refresh the page -
i need display img element without having refresh page see content.
<script> function init() { $('#picturebox').attr('src', picture); } </script> <body onload="init();"> <img id="picturebox" src=""></img> </body>
you should preload picture first(this cause picture shown immediately), can use picture dynamically.
<script> //preloading... var mypic = new image(); mypic.src = picture; $(window).load(function(){ $('#picturebox').attr('src', picture); }); </script> <body> <img id="picturebox" src="" /> </body> note in html5 standard img tag can not have empty property src
Comments
Post a Comment