views:

131

answers:

3

Given the html fragment

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;  
<html xmlns="http://www.w3.org/1999/xhtml" >  
  <head>
    <title>Test JQuery AppendTo</title>  
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;      
    </script>  
  </head>  
  <body>
    <div id="Test1">
      <p>Just some text</p>
    </div>
    <form name="FORMPOST" method="post" action="showform.aspx" id="FORMPOST" >
      <label for="Test2">Test Label</label>
      <input id="Test2" type="checkbox" />
      <img src=\"add2.jpg\">
    </form>
  </body>
</html>

and given that the add2.jpg image is in the same directory as the html code, why does the image not display? Note that if I move the image tag node to be inside the div node, it will display :(

Note the display does not appear regardless of whether I add the img tag at design time as above, or append it using the jQuery.appendTo function when the form loads.

A: 

Your image tag doesn't look correctly formed to me

<img src="add2.jpg" />

Does this work for you like the above?

Tommy
OP does need `/>` because this is XHTML.
Daniel Trebbien
+1  A: 

For one, you shouldn't have back slashes there for quotes. Can you give us a link to the page itself? Because that will work.

Kerry
Thanks - Slashes were a typo :(The page is in an internal app which is throwing an error in IE when loading the image dynamically with jQuery. I'll post the jQuery fragment that is causing the problem. FF does not throw an error - just fails to display the image. IE 8 throws a script error.
David Moorhouse
+1  A: 

Were the backslashes in <img src=\"add2.jpg\"> a typo? <img src=\"add2.jpg\"> should be <img src="add2.jpg" />.

You need the forward slash to end the img tag because you are using XHTML.

Daniel Trebbien
Thanks - slashes were a typo. Still have problems with fwd slash to close teh tag.
David Moorhouse