Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    How to trigger click on css child (envolving ID)


    I'm working on a usability issue on a website. I have a jquery accordion slider, each slide has a link to a category. Now what happens is that when I go to the category page by clicking on a slider, when the page loads, the sliders always opens the first slide. For example, if I click on the third slide, I would like that slide to be open when the page loads.

    This is similar to the :current I believe. I think to solve what I need I must trigger a click on the third slide that third slide page opens.

    I know I need a reference for a condition, so I have ID'd my body through this php code were it gets the page name from the url into variable $page and then into do body's ID:

    PHP Code:


    $page str_replace("/","",$page);

    $page str_replace(".php","",$page);

    $page str_replace("?s=","",$page);

    $page $page $page 'default'


    <body id="<?php echo $page ?>">
    Now I've been trying through Javascript to get the variable from php and trigger a click on the slide of the category it is opening:

    PHP Code:
    <script type="text/javascript">

    var bodyid = "<? $page ?>";

    if (bodyid == "energy") {

    $("document").ready(function() {
        setTimeout(function() {
            $("ul#accordion li:second-child).trigger('click');


    This is not working and I don't really know what's wrong and how to solve or search for help.

    Does anyone understand what I'm trying to do here? Thank you.

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Thanked 20 Times in 20 Posts
    you should probably take it to dynamic drive forums. They have an accordion script that allows what you're looking for and will help make adjustments if needed.
    NO Limits!! DHCreationStation.com
    For projects using MediaTypes (MIMETypes) visit E-BAM.net -(updated weekly)

    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts