1

I'm trying to apply different style to every first table row below a certain class using this code:

$(".my-class tr:first td").css({"color":"#0064CC","font-size":"15px","border-bottom-style":"none"});

The problem is that it only applies it to the first table it finds below that class.

What am I missing here?

4 Answers 4

3

Try the following :

$(".my-class").find("tr:first td").css({"color":"#0064CC","font-size":"15px","border-bottom-style":"none"});

Your previous code was only finding the first row and td, this will find every element with .my-class and find the first tr/td element of the found elements.

Sign up to request clarification or add additional context in comments.

1 Comment

Can you provide the HTML of the table you are using?
1

You can also try for precision

$(".my-class").find("tr td:eq(0)").css({"color":"#0064CC","font-size":"15px","border-bottom-style":"none"});

Comments

1

Change

 $(".my-class tr:first td")

to

$("table tr:first").has('.my-class').find('td')

Comments

0

try something like this

$(".my-class tr:first td").each(function(){
    $(this).css({"color":"#0064CC","font-size":"15px","border-bottom-style":"none"});
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.