Reputation: 20856
Im a newbie to JQuery and trying this code but for some reason I don't see the alert button being popped..
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
<script src="C:/jquery/jquery.js"></script>
<script>
$( document ).ready(function() {
$( "a" ).click(function( event ) {
alert( "The link will no longer take you to jquery.com" );
event.preventDefault();
});
});
</script>
<style>
a.test {
font-weight: bold;
}
</style>
</body>
</html>
Upvotes: 0
Views: 145
Reputation: 4544
Code is ok, this should work.
Try to replace
<script src="C:/jquery/jquery.js"></script>
by
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Upvotes: 0
Reputation: 419
I think that's not the right way to include the jquery script from your localhost, you can, for testing purposes (or even production) include it this way:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Remember to put in in your html header.
If you still want to include it from you local drive use this path:
file:///C:/jquery/jquery.js
Upvotes: 2