将Cs添加到具有特定类但存在多个类名的元素中

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

本文关键字:存在 元素 添加 Cs      更新时间:2024-03-09

我正在尝试将css添加到作为fullcalender 一部分的表中的"td"

日期单元格的类已从fc-day0添加到fc-day41
td元素如下所示:

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

我尝试了以下操作:

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

我感谢你的帮助=)

如果你想过滤掉你的td集合,并找到所有拥有fc-day1类的人,那么使用带有css选择器的filter:

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

要用类fc-day1瞄准TD,只需执行:

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

FIDDLE

您不需要jquery。

在一个文件css:

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

问候