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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:21:27+00:00 2026-05-14T03:21:27+00:00

I have a table where each row has 13 TD elements. I want to

  • 0

I have a table where each row has 13 TD elements. I want to show and hide the first 10 of them when I toggle a link. These 10 TD elements all have an IDs with the prefix “foo” and a two digit number for its position (e.g., “foo01”). What’s the fastest way to select them across the entire table?

$("td:nth-child(-n+10)")

or

$("td[id^=foo]")

or is it worth concatenating all of the ids?

$("#foo01, #foo02, #foo03, #foo04, #foo05, #foo06, #foo07, #foo08, #foo09, #foo10")

Is there another approach I should be considering as well?

  • 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-14T03:21:27+00:00Added an answer on May 14, 2026 at 3:21 am

    Use this

     $("td:lt(10)")
    

    I say this because you have ids which should be unique, meaning one row.

    You could also use $("tr").find("td:lt(10)") for multiple rows…but keep those IDs unique.

    But keep something in mind here, the speed of the selector is going to have minimal impact here. Redrawing a table means a lot of reflow calculations by the browser (this column is how wide based on all text, what wraps, etc). That’s what’s going to eat your time in this operation, the selector won’t have a huge performance impact since the vast majority of processing time for this will be spent after it runs.

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

Sidebar

Related Questions

I have a table with 3 rows. Each row has 3 td. The first
I have a HTML table where each row has two columns. First column is
I have a table where each row has a description field as well as
I have a table column where each row has one of three states, and
I have a table with many rows and each row has select lists. Something
I have a DB table in which each row has a randomly generated primary
I have a massive table with thousands of rows. Each row has a unique
I have this kind of table, it has many rows and each row has
I have a tableview with custom UITableViewCells, each row in the table has a
I have a table with rows in, and each row has a few <td>

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.