using jQuery for multiple purposes
-
OK I’m making a theme and am using jQuery for several things (in order that they are called:
1. I have a Lightbox 2 plugin. Called in wp_head(). (This plugin also calls its own jQuery file so I have no need to call one separately).
2. I have cufon text replacement. Called in the head just after wp_head(). (This is so it gets the jQuery file loaded with lightbox).
3. A custom js script I developed to collapse the sidebar widgets when the widget title is clicked. This script appears just after the cufon scripts.
So basically this portion of my
<head>looks like this:<?php wp_head(); ?> <!--Cufon Scripts --> <script src="<?php bloginfo("template_url"); ?>/cufon/cufon-yui.js" type="text/javascript"></script> <script src="<?php bloginfo("template_url"); ?>/cufon/Superclarendon_Rg_700.font.js" type="text/javascript"></script> <script type="text/javascript"> Cufon.replace('#header h1'); </script> <!--/Cufon Scripts --> <script type="text/javascript"> $(document).ready(function(){ $('.widget h2').click(function(){ // gets the parent div var parent = $(this).parents('.widget'); // checks if it's active var active = $(parent).hasClass('active'); // if it's active, it slides the div down, otherwise it slides it up if(active == true){ $(this).next().slideDown('fast'); $(parent).removeClass('active'); } else { $(this).next().slideUp('fast'); $(parent).addClass('active'); }; }); }); </script>The problem is that my custom script is not working. I developed and tested it on a lone simple html page but now I’ve added it to my theme it doesn’t work.
Firebug reports that $(document).ready is not a function. This is strange because viewing the page source shows that jQuery is loaded just before it. Any ideas?
The topic ‘using jQuery for multiple purposes’ is closed to new replies.