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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:48:22+00:00 2026-05-27T17:48:22+00:00

For example, I have 20 items all the same height, all the same class

  • 0

For example, I have 20 items all the same height, all the same class “some_class”.
The first item of the twenty has an id of “first_item”.

When I do $('.some_class').height(); I get 0 (which is wrong). But when I do $('#first_item').height(); it works and I get a value.

This baffles me. Why might this be? I can’t really share the web page because its a private page.

EDIT: Interesting to note that .width() works just fine, and I get the same value calling it on #first_item or ‘.some_class’.

  • 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-27T17:48:22+00:00Added an answer on May 27, 2026 at 5:48 pm

    Because you’ll probably find that the class selector is returning more than one element. In this case, height() returns the value of the first element (this is consistent throughout the jQuery get methods); which is probably not the one you want.

    If you want the height of each of the element, you should iterate over them with each;

    $('.some_class').each(function () {
        var myHeight = $(this).height();
    });
    

    jQuery height docs;

    Get the current computed height for the first element in the set of matched elements.

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

Sidebar

Related Questions

I have the following XML example <?xml version=1.0?> <test> <items> <item>item 1</item> <item>item 2</item>
Let's say I have many items with click event (all have same element name
I have a number of elements with the same class like this: <html> <head><title>example</title>
I have the following menu items: <ul> <li class=static> <a class=static menu-item href=/mySites/AboutUs>About Us</a>
I have an unordered list with a background-image set. All list-items have the same
Case example: I have a long list of items, and when I put my
For example, we have 19 items on the repeater datasource. And we wanted to
I have a List that contains items, for example: 1) https:\\10.12.23\\ 2) https:\\12.23.12.25\\ 3)
Simplified for example, I have two tables, groups and items . items ( id,
How to know if all the cells have the same value in some column

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.