ObsidianEagle
ObsidianEagle

Reputation: 5

My jQuery code doesn't seem to be affecting my web page

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);
    });
});

Upvotes: 0

Views: 66

Answers (3)

Biswajit
Biswajit

Reputation: 2506

 <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.

Upvotes: 0

Alex.Zhe.Han
Alex.Zhe.Han

Reputation: 76

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/

Upvotes: 0

Sridhar R
Sridhar R

Reputation: 20408

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/

Upvotes: 2

Related Questions