0

几天来,我一直在努力使用 jQuery 尝试编写一个脚本来替换论坛聊天框中动态创建的跨度样式颜色。
两个元素都包裹在一个td元素class="chat"和一个跨度中,style="color:green"就像这样

<td class="chat"><span style="color:darkgreen;">test</span></td>

例如,我尝试编写的脚本(可悲的是没有工作);

$(".chat:contains('darkgreen')").css("color", "rgb(255, 111, 7)");
$(".chat:contains('darkgreen')").css("font-weight", "bold");
$(".chat:contains('darkgreen')").css("text-shadow", "bold");
$(".chat:contains('darkgreen')").css("text-shadow", "rgb(0, 0, 0) 1px 1px 1px");
$(".chat:contains('darkgreen')").css("text-shadow", "rgb(255, 111, 7) 1px 0px 6px");

我还尝试使用其他一些类(td例如他们想要的跨度颜色与我的 CSS?chattd

4

1 回答 1

0

您可以通过以下方式访问它

$(".chat>span[style='color:darkgreen;']")
.css({
  "color":"rgb(255, 111, 7)",
  "font-weight": "bold",
  "text-shadow": "bold",
  "text-shadow": "rgb(0, 0, 0) 1px 1px 1px",
  "text-shadow": "rgb(255, 111, 7) 1px 0px 6px"
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<table>
  <tr>
    <td class="chat"><span style="color:darkgreen;">test</span></td>
  </tr>
</table>

于 2017-09-18T21:42:09.040 回答