Html and Javascript help

3 replies
Hi i need help with this one something is wrong, somehow it does not connect to javascript/jquery i think.

Untitled Document

Here is the orginal
Edit fiddle - JSFiddle

Here is my code:
Code:
<html>
<head>
<script src="jquery-1.7.2.min.js"></script>
<script src="jquery-ui.js"></script>
<script src="java.js"></script>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css">

</head>

<body>
<script type="text/javascript">
jQuery(".chair").click(function(){
    jQuery(".avatar").appendTo(jQuery(this));
});
</script>
<div class="room">
<div class="avatar">
</div>
<div style="position:absolute; top:20px; left:50px;" class="chair">
</div>
<div style="position:absolute; top:20px; left:75px;" class="chair">
</div>
<div style="position:absolute; top:40px; left:40px;" class="table">
</div>
<div style="position:absolute; top:70px; left:50px;" class="chair">
</div>
<div style="position:absolute; top:70px; left:75px;" class="chair">
</div>

</div>
</body>
</html>
Thanks
#html #javascript
  • Profile picture of the author DLycanthus
    Move your script down just before your closing </body> tag.

    A good way to see this, is to go to your JSFiddle link, and right click inside the frame with your 'table?' and choose view frame source.

    You generally want to put all scripts at the bottom, so everything else is able to fully load. There are some functions you can add to nearly any script that ensure full page load, but that's another question, and more complicated.
    {{ DiscussionBoard.errors[10173031].message }}
    • Profile picture of the author steffanmax
      Originally Posted by DLycanthus View Post

      Move your script down just before your closing </body> tag.

      A good way to see this, is to go to your JSFiddle link, and right click inside the frame with your 'table?' and choose view frame source.

      You generally want to put all scripts at the bottom, so everything else is able to fully load. There are some functions you can add to nearly any script that ensure full page load, but that's another question, and more complicated.
      Thanks it works now And i learned something.. have a nice day my friend
      Signature
      {{ DiscussionBoard.errors[10173040].message }}
  • Profile picture of the author DLycanthus
    Glad I could help
    {{ DiscussionBoard.errors[10173052].message }}

Trending Topics