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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:38:10+00:00 2026-05-22T18:38:10+00:00

How do I assign a style to every first cell of every row in

  • 0

How do I assign a style to every first cell of every row in a table?

$("#myTable tr td:first").addClass("black");
  • 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-22T18:38:11+00:00Added an answer on May 22, 2026 at 6:38 pm

    Use the :first-child pseudo class instead of :first.

    $("#myTable tr td:first-child").addClass("black");
    

    The :first pseudo class actually selects the first element that was returned in your list. For example, $('div span:first') would return only the very first span under the first div that happened to be returned.

    The :first-child pseudo class selects the first element under a particular parent, but returns as many elements as there are first children. For example, $('table tr td:first-child') returns the first cell of every single row.

    When you used :first, it was returning only the first cell of the first row that happened to be selected.

    For more information, consult the jQuery documentation:

    • http://api.jquery.com/first-selector/
    • http://api.jquery.com/first-child-selector/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to assign display style (CssClass) to every CheckBox within CheckBoxList. I would
I need to assign a style to a table with the class tableClass. I
I'm trying to assign DataContext to a MenuItem, which is part of ListBox. <Style
I'd like to assign a style to a HTML element - but only in
I know that I can assign an onclick action to <input type=button -style buttons.
I know that you can assign a class to the generated table by using
I am trying to assign a style for each icon in a List component.
With c-style strings, how do you assign a char to a memory address that
I got a table and i assign the click event via .live() to each
I'm trying to assign an object in the style of an associate array in

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.