我试图根据url中是否包含字符|来设置表中的表单元格样式(不要问,处理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");
});