我正在尝试根据是否包含字符 | 来设置表格中的表格单元格样式。在网址中与否(不要问,与 SharePoint 打交道)。
示例 HTML;
<table>
<tr>
<td class="ms-cal-workitem">
<table>
<tr>
<td class="ms-cal-monthitem">
<a href="http://localhost:4657/1">Event 1</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="ms-cal-workitem">
<table>
<tr>
<td class="ms-cal-monthitem">
<a href="http://localhost:4657/1|435348578-kfsd-sdfsf-sfsf-324ewwer">Event 2</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
在任何具有 ms-cal-workitem 类的表格单元格中,包含超链接的背景颜色应为红色。唯一的例外是任何具有 ms-cal-monthitem 类的表格单元格,其中包含具有字符 | 的超链接。在他们的 href 属性中。
到目前为止我得到了什么;
$(document).ready(function() {
$("td.ms-cal-workitem:has(a[href*='|'])").css("background-color", "#ffff99");
$("td.ms-cal-workitem:has(a:not[href*='|'])").css("background-color", "#ffcc33");
});