Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6021719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:45:16+00:00 2026-05-23T03:45:16+00:00

How can I trigger the following function for a specific DIV $(document).ready(function() { if($(‘div.trigger’).length

  • 0

How can I trigger the following function for a specific DIV

$(document).ready(function() {
    if($('div.trigger').length > 0) {
        $('div.trigger').click(function() {
            if ($(this).hasClass('open')) {
                $(this).removeClass('open');
                $(this).addClass('close');
                $(this).next().slideDown(100);
                return false;
            } else {
                $(this).removeClass('close');
                $(this).addClass('open');
                $(this).next().slideUp(100);
                return false;
            }           
        });
    }
});

My html looks like this:

<div class="trigger open"><a href="#"><strong>Dropdown 1</strong></a></div>
<div class="cnt">
    <a href="?library&delasset=1">foo</a><br>
    <a href="?library&delasset=2">bar</a>
</div>

<div class="trigger open"><a href="#"><strong>Dropdown 2</strong></a></div>
<div class="cnt">
    <a href="?library&delasset=3">baz</a><br>
    <a href="?library&delasset=4">boo</a>
</div>

My solution was to this:

$(document).ready(function()
{
    $('div.trigger:eq(<?=$_GET[exp];?>)').trigger('click');
});

Thanks for the help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:45:17+00:00Added an answer on May 23, 2026 at 3:45 am
    $('div.trigger:eq(0)').trigger('click');//trigger click event of the Oth element
    $('div.trigger:first').trigger('click');//trigger click event of first
    $('div.trigger:last').trigger('click');//trigger the click of last one
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: $(#Table1 tbody).children().each(function(e){ $(this).bind('click', function(){ // Do something here },
Hy , I have the following code for mai tabs ... $(document).ready(function() { $(#continut_right
I have the following code - http://jsfiddle.net/vcvsb/1/ - per $(document).ready(function(e) { $(input#autocomplete).autocomplete({ source: [c++,
In a Windows Form window, multiple events can trigger an asynchronous method. This method
How can I set a delayed trigger in JavaScript to execute a function after
Like how the click() can be used to trigger a click event on an
I have this Trigger in Postgresql that I can't just get to work (does
Considering the following PHP class: class someObject { public function broken(){ return isset($this->something()) ?
I suppose the following code: jQuery(#mybutton).click(function(){ //do something }); How could I recall to
Can anyone tell me why the following page doesn't trigger an alert when it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.