tags:

views:

33

answers:

1

Possible Duplicate:
Problem working with jQuery

Hello! The follow is the code i've been using and i dont understand why its not working at all! :

<!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"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<script language="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;

<script language="text/javascript">


function hide() {

$("#Layer1").hide("fast");

}
</script>
<style type="text/css">
<!--
body {
background-color: #000000;
}
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 179px;
top: 3px;
}
#Layer2 {
position:absolute;
width:101px;
height:80px;
z-index:2;
left: 570px;
top: 473px;
}
-->
</style></head>



<body>
<div id="Layer1"><img src="body.jpg" width="842" height="554" /></div>
<div id="Layer2"><img src="close.jpg" width="63" height="64" OnClick="hide()"/></div>
</body>
</html>

I've used dreamweaver for the design.

Thanks!

+1  A: 

It's not language="text/javascript", but type="text/javascript".

Furthermore, This is really a problem you should be solving using the $(document).ready() function, and not something as unweildy as an inline onClick, to which jQuery's event binding is partially a solution for:

$(document).ready(function(){

    $('#Layer2').click(function() {
        $('#Layer1').hide();
    });

});
Robert Elwell
`It's not language="text/javascript", but type="text/javascript".` Actually, this is incorrect; JavaScript's MIME type is `application/javascript`.
strager
@strager - `text/javascript` is the *default* MIME type in HTML5, and it's the most common in HTML4, there's nothing wrong with `text/javascript`...
Nick Craver
@Nick Craver, I was mistaken; `text/javascript` is *obsolete*; `application/javascript` is not.
strager
@strager - Says who? :) As I said, it's the default MIME type in HTML5: http://dev.w3.org/html5/spec/Overview.html#attr-script-type *Edit:* I see where the confusion is, this doesn't govern HTML standards: http://tools.ietf.org/html/rfc4329 HTML4/5 is what this application is, and it's not obsoleted for that purpose.
Nick Craver