JS-newbie trying to get jQuery to work
First off: I don't have any experience with JavaScript. I've been trying to follow a few tutorials on tabbed navigation, but I just can't get them to work.
The last one I tried was this one:
http://apricotstudios.wordpress.com/200 ... -tutorial/
I'm running it on a local wordpress installation. I've included this in the header:
-
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#mainBig div').hide(); // Hide all divs
$('#mainBig div:first').show(); // Show the first div
$('#mainBig ul li:first').addClass('active'); // Set the class of the first link to active
$('#mainBig ul li a').click(function(){ //When any link is clicked
$('#mainBig ul li').removeClass('active'); // Remove active class from all links
$(this).parent().addClass('active'); //Set clicked link class to active
var currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
$('#mainBig div').hide(); // Hide all divs
$(currentTab).fadeIn('slow') //fade in target div
return false;
});
});
</script>
And this is the html:
-
<div id="mainBig">
<h3 class="main big">Værstatistikk</h3>
<ul id="tabMenu">
<li class="temperatur"><a href="#temperatur">Temperatur</a></li>
<li class="nedbor"><a href="#nedbor">Nedbør</a></li>
<li class="lufttrykk"><a href="#lufttrykk">Lufttrykk</a></li>
<li class="fuktighet"><a href="#fuktighet">Luftfuktighet</a></li>
<li class="straling"><a href="#straling">UV-stråling</a></li>
<li class="diverse"><a href="#diverse">Diverse</a></li>
</ul>
<div id="temperatur"><? include "weatherlink/stats.htm"; ?></div>
<div id="nedbor"><? include "weatherlink/stats.htm"; ?></div>
<div id="lufttrykk"><? include "weatherlink/stats.htm"; ?></div>
<div id="fuktighet"><? include "weatherlink/stats.htm"; ?></div>
<div id="straling"><? include "weatherlink/stats.htm"; ?></div>
<div id="diverse"><? include "weatherlink/stats.htm"; ?></div>
</div>
And nothing happens. It's as if there were no js files. I've checked that the sources are correct. What am I doing wrong?