Simplest case of loading an image via jQuery -
i'm not having luck pulling image file image element using jquery. looks pretty simple, i'm missing elementary. (i'm complete jquery tyro, i've made silly mistake somewhere.)
all files in same directory (html, jquery-1.10.2.min.js, myimage.png).
the text shows up, no image.
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript" src="jquery-1.10.2.min.js"></script> </head> <body> beforeimage <img id="myimageelement" src="" /> afterimage <script type="text/javascript"> $('#myimageelement').load('myimage.png'); </script> </body> </html>
you should try setting src
property of img
tag instead.
$('#myimageelement').attr("src","myimage.png");
Comments
Post a Comment