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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:17:49+00:00 2026-05-29T07:17:49+00:00

I am looking a better method than find to find all the elements within

  • 0

I am looking a better method than “find” to find all the elements within an element:

<table>
  <tr>
    <td class="test">
      Test
    </td>
  </tr>
  <tr>
    <td class="test">
      Test
    </td>
  </tr>
  <tr>
    <td class="test">
      Test
    </td>
  </tr>
</table>

This is structure and and I have jquery of table as $table

I am willing to do something like this:

$table.find('.test');

Find is a very expensive call. I need a better way to do it. I know I can do it with direct selectors like this:

$('table .test');

But I am looking for an alternative for find which performs better. Find performs really bad especially in IE.

  • 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-29T07:17:50+00:00Added an answer on May 29, 2026 at 7:17 am

    find is slow in IE because IE does not implement a native getElementsByClassName. The fastest solution is apply knowledge of your DOM structure to the function that selects the elements. It is less flexible but always will be the fastest solution. In this case, it looks like the only elements that have the test class are td:

    var rows = $table[0].rows, cells, i, j, numRows, numCells, result = [];
    for(i = 0, numRows = rows.length; i<numRows; i++) { //Iterate over the table's rows
        cells = rows[i].children;
        for(j = 0, numCells = cells.length; j<numCells; j++) { //Iterate over the cells in the row
            if(cells[j].className == "test") { //Won't be valid if the cells have more than one class
                result.push(cells[j]);
            }
        }
    }
    

    This is just an example. Like I said, you sacrifice flexibility for speed, so you may need to tweak it to adapt to your particular structure but the principle remains.

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

Sidebar

Related Questions

Is there a better method than loop with strpos()? Not i'm looking for partial
I am looking for a better solution than what we currently have to deal
Alex explained what I'm looking for much better than I have: You want an
I'm looking for a better way to do the following query. I have a
I am looking for a better primary key than the autonumber data type, namely
Question Summary: Is there a better method than the one posted below to implement
Looking for a lightweight way to find objects within a radius. So far the
This is more a curiosity question than a pressing one. This question is looking
I'm looking for a better sortable JavaScript library in order to make some elements
I'm looking for a best practice solution.... I have table that holds products called

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.