LightMonk
LightMonk

Reputation: 163

Add Css to an element with specific class but multiple class names present

I'm trying to add css to a 'td' in a Table that is part of the fullcalender

The day cells have classes added fc-day0 to fc-day41
td element looks like this:

<td class="fc-mon fc-widget-content fc-day1">

I tried following:

$("td").filter("fc-day1")
       .css("background", "red");

$("td").find("fc-day1")
       .css("background", "red");

$("td").find($('td[class*=".fc-day1"]'))
       .css("background", "red");

I appreciate your help =)

Upvotes: 2

Views: 108

Answers (3)

esmoreno
esmoreno

Reputation: 666

You don't need jquery.

In a file css:

<style>
table td .fc-day1{
  background:red;
}
</style>

Regards

Upvotes: 0

voigtan
voigtan

Reputation: 9031

if you want to filter out your collection of td and find all who has the class fc-day1 then use filter with a css selector:

$("td").filter(".fc-day1")
    .css("background", "red");

Upvotes: 1

adeneo
adeneo

Reputation: 318202

To target a TD with the class fc-day1 just do:

$("td.fc-day1").css("background", "red");

FIDDLE

Upvotes: 1

Related Questions