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

  • Home
  • SEARCH
  • 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 7187021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:45:17+00:00 2026-05-28T18:45:17+00:00

I have this piece of code: $(document).on(click, #breadNavMain, function() { for(var i = 0;

  • 0

I have this piece of code:

$(document).on("click", "#breadNavMain", function() {
    for(var i = 0; i < getActiveSlides().length; i++) {
        $("#studentWrapper").trigger("click");
    }
});

The method getActiveSlides() will return the slides (as an array) currently activated for my application. What’s import is that I am getting the number of slides that are active. For anything over 1 active slide, the loop above does not work. If I have 3 active slides (for example), it will only call the .trigger() method once. Within my click handler, if I instead use:

$("#studentWrapper").trigger("click");
$("#studentWrapper").trigger("click");
$("#studentWrapper").trigger("click");

It will work just fine. The problem is that I don’t know how many times I’ll need to call the .trigger() method so I am unable to do this manually. I wanted to call it inside of a loop like I tried to above. Is there anyway to get .trigger() to work inside of a loop?

  • 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-28T18:45:18+00:00Added an answer on May 28, 2026 at 6:45 pm

    It should actually work fine, but I am skeptical that something is wrong inside getActiveSlides method. May be after first click it is not returning the correct number of active slides. You can take its return value into a variable and then execute your code. Try this.

    $(document).on("click", "#breadNavMain", function() {
        var activeSlidesLen = getActiveSlides().length;
        for(var i = 0; i < activeSlidesLen; i++) {
            $("#studentWrapper").trigger("click");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code: $(#faq).click(function () { var url = $.get(faq, {
I have this piece of code: var myObj = function () { this.complex =
I have the following piece of code: function checkAmount() { var PayField = document.getElementById('paymentamount');
I have an issue I have this jQuery code: $(document).ready(function(){ $(#follow).click(function(){ $.ajax({ type: 'POST',
I have this piece of code written in jQuery and PHP: <script type=text/javascript> $(document).ready(function(){
I have this piece of code in javascript: var catId = $.getURLParam(category); In my
I have this piece of simple code. <html> <head> <script type=text/javascript> function changeText() {
In javascript suppose you have this piece of code: <div> <script type=text/javascript>var output =
I have this simple html piece of code, whenever I click on any of
I have the following piece of code: <html> <head> <script src=myplugin.js /> <script> $(document).ready(function()

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.