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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -