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 6337861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:19:56+00:00 2026-05-24T19:19:56+00:00

How do I count dynamically generate elements with the same class in jquery? I

  • 0

How do I count dynamically generate elements with the same class in jquery?
I found a similar question, but unfortunately it didn’t work.
jQuery counting elements by class; what is the best way to implement this?

I did something like this which I based from the answers:

$('.capital_class').live('blur', function(){

alert($(this).length);
});

The elements with a class of capital_class are dynamically generated. But I always get the length of 1, whenever I blur. How do I get this correctly?

  • 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-24T19:19:59+00:00Added an answer on May 24, 2026 at 7:19 pm

    Change the alert to this:

    alert($('.capital_class').length);
    

    Remember the event is called on a single element so this is just a single element — you have to have jQuery query the dom after the event happens. (The first query just sets up the live handling to create the event handlers.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I generate my check boxes dynamically: for (int i = 0; i < dtCommon.Count;
I have the following Helper class to generate a <ASP:Table> control dynamically. using System;
How can I count the number of elements in an array, because contrary to
I need a way to dynamically populate this query... to avoid repeating the same
I currently am using a dynamically generated list view in jQuery mobile to display
i've got a ComboBox that i generate dynamically and fill with some items. i
I am using this code to generate the textbox dynamically by using the JavaScript.
I want to get the count of the results of a dynamically-generated HQL query,
I need to iterate through a bunch of dynamically generated fields, but this doesn't
As the title implies I'm trying to generate Facebook Open Graph meta tags dynamically,

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.