Strange behaviour Jquery
# May 19, 2009 at 3:32 am
I’ve got two problems using script and a man’s best friend (google) can’t give me an answer.
This gives an error in firebug: $ not definedCode:
But when I use the next lines of code, it doesCode:
I can get it defined but why doesn’t it work like it should and like it works on all the other sites?
The following just doesn’t do anythingCode:# May 19, 2009 at 5:22 am
I always use the google hosted version of jQuery thus:Code:
But if you want to use the version bundled with WordPress you can use this line:Code:< ?php wp_enqueue_script(jquery); ?>
And as regards the conflict, change $ to ‘jQuery’ so you would have:Code:# May 19, 2009 at 2:42 pm
Still no successCode:< ?php wp_enqueue_script(jquery); ?>
this now gives me "Jquery not defined" so still the same error.
When i putCode:
I don’t get the error but the script doesn’t do anything. When i’m learning something i try to do stuff myself instead of copy-paste from other sites. But even a copy-paste from the original site doesn’t do anything# May 19, 2009 at 3:15 pm
First thing I notice isCode:Jquery
and the second thing is the path to your image. I’m guessing it is in with your theme files so the path should look something like this:Code:‘< ?php bloginfo('template_directory'); ?>/images/affiches/event_small.png’# May 23, 2009 at 2:46 pm
I finally found the problem.
The problem wasn’t the function I called, but when I called it:Code:< ?php wp_enqueue_script('innerfade', 'https://cdn.css-tricks.com/wp-content/themes/kclub/js/jquery.innerfade.js', array('jquery') ); ?>
< ?php wp_head(); ?>
I have to "wp_enqueue" the script before <?php wp_head(); ?> and the script itself has to come after <?php wp_head(); ?> I placed everything above <?php wp_head(); ?>
Spent hours and hours on this and I can’t believe it was something so small like this. But it makes sense
You must be logged in to reply to this topic.