Forums

Tabbed Widgets
Can't use jquery to select tabbed widget elements (2 posts)

  1. PopTopJosh
    Member
    Posted 1 year ago #

    So I have the tabbed widget plugin loading and functioning correctly. I'm trying to use the following jquery code to just identify the number of ul's in hopes of eventually adding some styling to li's contained in there:

    jQuery(document).ready(function($){
    alert($('ul.tw-tabbed-nav').length + ' elements!');
        });

    The problem is my script file that contains the above, loads before the plugin finishes setting up. I noticed that for a split second when my page loads the individual widgets are displaying individually before the tabbed widget loads them into tabs. Anyone know of a way to make sure the above function doesn't fire until after the plugins have finished loading? For the record, this is how my script file is being added to the site via my functions file:

    if ( !is_admin() ) { // instruction to only load if it is not the admin area
       // register your script location, dependencies and version
       wp_register_script('vtdscripts',
           get_bloginfo('stylesheet_directory') . '/js/vtdscripts.js',
           array('jquery'),
           '1.0', 1 );
       // enqueue the script
       wp_enqueue_script('vtdscripts');
    }

    Thanks for the help all!

  2. Kaspars
    Member
    Posted 1 year ago #

    Try counting the number of widgets inside the tabbed widget:

    alert($('.tabbed-widget .widget').length + ' elements!');

    where .widget is the classname of your standard widgets.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic