Feel free to yell abuse at me if I'm being stupid here, but I'm getting confused. It seems like everything should work fine :/ I've triple checked the file locations and everything is fine
I have this in the head:
<head>
<meta charset="utf-8">
<title>Website</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/functions.js"></script>
</head>
I have a list of links like this:
<ul class="menu">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
And in functions.js I have this...
console.log('WTF.. THIS LOGS IN THE CONSOLE!?!?!?!');
// debugging purposes
alert($('a').attr('href'));
$('.menu li a').click(function(e){
alert('hey');
e.preventDefault();
});
I get an alert saying 'undefined' and when I click on a link, default actions is prevented and I don't get an alert...
The conclusion I've come to is there was a problem somewhere with the jQuery... but I just can't find whats going on here
$(document).ready(function() { /* your code */ });or$(function() { /* your code */ });??