• Resolved martyn

    (@marty2010)


    Hi all,
    I’ve tried many jquery codes with no satisfaction.
    I need to use a simple jquery

    var $j = jQuery.noConflict();
    $j(function() {
        $j('.dropdown-trigger').on('click', function() {
            $j(this).next().toggle();
        });
    });

    to have a dropdown effect, so here https://jsfiddle.net/0rven7zt/3/ it works well.

    Note: using ‘inspection page’ > ‘console’ there’s this message about the customizr theme
    NOK => browserDetect::addBrowserClassToBody => TypeError: t.browser is undefined tc-scripts.min.js:1:73900

    Many thank’s

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hi,
    your “simple” jQuery solution doesn’t work because of the WordPress autop which is putting a “<p>” element between your dropdown trigger and the element you want to collapse/uncollapse (a ul), which you want to target with the jQuery next() function. This issue is not theme related 😉

    Try with .nextAll('ul') in place of .next().

    This ‘error’ message, which is not blocking and has no real impact on your code:

    Note: using ‘inspection page’ > ‘console’ there’s this message about the customizr theme
    NOK => browserDetect::addBrowserClassToBody => TypeError: t.browser is undefined tc-scripts.min.js:1:73900

    is related to the fact that:
    1) you are (or a plugin is) overriding the WordPress jQuery with https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
    2) you’re not loading (WordPress usually does it) the jquery-migrate library that provides the support for jQuery.browser (hence the “error” you see in the console).

    Hope this helps.

Viewing 1 replies (of 1 total)

The topic ‘my jquery doesn’t works’ is closed to new replies.