Reputation: 1
This is pretty simple but I can't figure out why only some parts of the Javascript execute and others don't. My html file is just a (div) and I want the javascript to change the colors of the (div) when the mouse hovers over it and then back to normal after leaving it.
The html file is...
<!DOCTYPE html>
<html>
<head>
<title>Button Magic</title>
<link rel='stylesheet' type='text/css' href='stylesheet.css'/>
</head>
<body>
<div><br/><strong>Click Me!</strong></div>
<script type='text/javascript' src='script.js'></script>
</body>
</html>
Here is the javascript file. It's saved as script.js and to test if it was even executing, I created an alert to comes up, and it does, so it must be a problem below that I cannot see.
alert("test");
$(document).ready(function(){
$('div').mouseenter(function(){
$('div').fadeTo("fast",1);
});
$('div').mouseleave(function(){
$('div').fadeTo("fast",0.5);
});
});
Upvotes: 0
Views: 83
Reputation: 36438
You never actually included jQuery, so all of the jQuery code is failing.
Add:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
before the other script
tag.
Upvotes: 2