#
February 14, 2010 at 3:47 pm
I am having similar problems. I am trying to create a simple jquery accordion effect for a gym class timetable.
I have added
Code:
< ?php wp_enqueue_script("jquery"); ?>
< ?php wp_head(); ?>
To the Header.php
and linked to my script just under
Code:
< ?php wp_head(); ?>
with
Like Chris mentions in his WordPress book!
Here is the jquery file
Code:
function initMenus() {
$(‘ul.menu ul’).hide();
$.each($(‘ul.menu’), function(){
$(‘#’ + this.id + ‘.expandfirst ul:first’).show();
});
$(‘ul.menu li a’).click(
function() {
var checkElement = $(this).next();
var parent = this.parentNode.parentNode.id;
if($(‘#’ + parent).hasClass(‘noaccordion’)) {
$(this).next().slideToggle(‘normal’);
return false;
}
if((checkElement.is(‘ul’)) && (checkElement.is(‘:visible’))) {
if($(‘#’ + parent).hasClass(‘collapsible’)) {
$(‘#’ + parent + ‘ ul:visible’).slideUp(‘normal’);
}
return false;
}
if((checkElement.is(‘ul’)) && (!checkElement.is(‘:visible’))) {
$(‘#’ + parent + ‘ ul:visible’).slideUp(‘normal’);
checkElement.slideDown(‘normal’);
return false;
}
}
);
}
$(document).ready(function() {initMenus();});
yet when i addd the html code in the page when i preview it there is no jquery in motion.
Does anyone have an idea of where i am going wrong?
This is my first attempt at adding jquery in wordpress without using a wordpress plugin.
Just noticed this thread is in the CSS Section. Not sure why!