问题描述:

I've tried using the google api and my own jQuery.js file, and I'm checked it through a lot and my javascript code seems to be good, so I'm guessing it's something obvious between linking jQuery to the web page that I'm missing

Here's the code on JSFiddle

<!DOCTYPE html>

<html>

<head>

<title>COMPUTERS.</title>

<link rel="stylesheet" type="text/css" href="cstyle.css">

<script type="text/javascript" src="cscript.js"></script>

</head>

<body>

<div id="navhead" align="center">

<div id="navleft" class="nav">

<p class="valign">Copyright and Patents</p>

</div>

<div id="navcentre" class="nav" align="center">

<p class="valign">Computer Misuse</p>

</div>

<div id="navright" class="nav">

<p class="valign">Data Protection</p>

</div>

</div>

</body>

</html>

Javascript:

 $(document).ready(function(){

$(".nav").mouseenter(function(){

$(this).fadeTo("slow", 1);

});

$(".nav").mouseleave(function(){

$(this).fadeTo("slow", 0.5);

});

});

网友答案:

Where is the jquery.js

Include that in your file to work..

Add this line before your js

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Updated Fiddle http://jsfiddle.net/hzE4M/2/

网友答案:

I tried your code in JSFiddle. It works.

$(".nav").mouseenter(function(){
    $(this).fadeTo("slow", 1);
});
$(".nav").mouseleave(function(){
    $(this).fadeTo("slow", 0.5);
});

http://jsfiddle.net/Alex_Zhe_Han/EmJZQ/

网友答案:
 <head>
        <title>COMPUTERS.</title>
        <link rel="stylesheet" type="text/css" href="cstyle.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script type="text/javascript" src="cscript.js"></script>
    </head>

your code is ok .just add this line.

相关阅读:
Top