0

jQuery for some reason isn't working.I'd like to know what the problem is.Here is my code :

<script language="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>    
<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"></div>
<div id="Layer2" onclick="hide()"></div>
</body>
</html>

Thanks! :)

3
  • 1
    Which part isn't working? Here's your code, seems to do what you're after: jsfiddle.net/nick_craver/58RU5 Commented Aug 7, 2010 at 15:07
  • What is the expected behavior you're not seeing? Commented Aug 7, 2010 at 15:08
  • it probably isn't the problem, but you should use <script type="text/javascript">, and not "language" attribute. Commented Aug 7, 2010 at 15:10

2 Answers 2

3

You seem to be confusing the form of the script tag that goes:

<script type="text/javascript">

with the one that goes:

<script language="javascript">

(see e.g. here for some explanation). Why not fix your tags to use just type= instead? Not sure whether that's all your problem (after spotting this one I think it needs to be fixed even if there were others;-) but it's confusing me and could be confusing your browser;-).

Sign up to request clarification or add additional context in comments.

Comments

0

I doubt it's the problem, but trying changing your function name from hide(), which is a jQuery function, to something else like hideDiv()

Since hide() isn't being used with the jQuery tag ($.hide()) I doubt this is the issue, but worth a shot I guess.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.