WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Some jQuery functionality loading, but .click function not working (4 posts)

  1. quomo
    Member
    Posted 2 years ago #

    I am working with a custom themed wordpress site that only uses static pages for content management (no posts).

    I am trying to clean up some of the pages so that the content is presented with jQuery tabs instead of link after link after link going down the page.

    I currently have the tabbed content showing (with only the first tab showing, so it looks like the jQuery .hide()function is working. But when I click on the tabs, the content doesn't change (though it does work outside of wordpress). (example: http://datadrivendetroit.org/toolbox/).

    I am using the code I found here: http://justintadlock.com/archives/2007/11/07/how-to-create-tabs-using-jquery

    header.php looks like this (yes, it's a bit of a mess):

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I am not seeing any relevant errors in Firebug and am confused why it seems to be all loaded and should be working, though only goes half the way.

    any help would be greatly appreciated.

  2. quomo
    Member
    Posted 2 years ago #

    Sorry, here are pastebin links to the:
    header.php file - http://pastebin.com/gwwEBVyj
    tabs.js file (which is connected at line 51 of header.php, jQuery was undefined if it were placed anywhere above <?php wp_head(); ?> on line 49 of header.php ) - http://pastebin.com/PLCsdS7Y

    example link was malformed by extra parenthesis: http://datadrivendetroit.org/toolbox

  3. markparolisi
    Member
    Posted 2 years ago #

    You should really load your scripts properly by attaching them to the wp_enqueue_scripts action

    Also, your jQuery is already run in no-conflict when you do this...

    jQuery(document).ready(function($) { }

    everything in that function is now safe to use the $ selector instead of jQuery

    review this page and see if your problem persists.
    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    BTW, what does your JS console say the errors are?

  4. quomo
    Member
    Posted 2 years ago #

    Yes, you were right. I wasn't getting any JS error when clicking on the tabs before, yet it still didn't work.

    When I used wp_enqueue_scripts instead (and put tabs.js above <?php wp_head(); ?), I started seeing the error that my $ was not defined, so I removed the no-conflict, used the $ selector and now it works.

    well done. marking this as resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic