Document ready script in wphead

Community Forums Forums Design Tips and Tricks Document ready script in wphead

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  Susan 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #80252

    nrwilliams
    Member
    Post count: 6

    I have a script (below) that was added to the wp_head() in the genesis theme settings area. It causes the accordian to work on the page. My issue is that I want to have the script load from the functions.php so I don’t have to have it in the theme settings area. Everytime I try the enque scripts function the accordian stops working.

    Thanks

    <script>
    $(document).ready(function()
    {
    //Add Inactive Class To All Accordion Headers
    $(‘.accordion-header’).toggleClass(‘inactive-header’);

    //Set The Accordion Content Width
    var contentwidth = $(‘.accordion-header’).width();
    $(‘.accordion-content’).css({width:”100%”});

    //Open The First Accordion Section When Page Loads
    $(‘.accordion-header’).first().toggleClass(‘active-header’).toggleClass(‘inactive-header’);
    $(‘.accordion-content’).first().slideDown().toggleClass(‘open-content’);

    // The Accordion Effect
    $(‘.accordion-header’).click(function () {
    if($(this).is(‘.inactive-header’)) {
    $(‘.active-header’).toggleClass(‘active-header’).toggleClass(‘inactive-header’).next().slideToggle().toggleClass(‘open-content’);
    $(this).toggleClass(‘active-header’).toggleClass(‘inactive-header’);
    $(this).next().slideToggle().toggleClass(‘open-content’);
    }

    else {
    $(this).toggleClass(‘active-header’).toggleClass(‘inactive-header’);
    $(this).next().slideToggle().toggleClass(‘open-content’);
    }
    });

    return false;

    });
    </script>

    http://www.xptheme.xpgraphics.org
    #91590

    Susan
    Moderator
    Post count: 9597
    This reply has been marked as private.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.