Style table classes using jQuery

I am trying to create table cells in a table based on whether the character contains | in the URL or not (don't ask when dealing with SharePoint).

HTML example;

<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>

Any cell in the table with the ms-cal-workitem class that contains the hyperlink must have a red background color. The only exception to this are any table cells with the ms-cal-monthitem class that contain a hyperlink with the symbol | to your href resource.

What I still have

        $(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");
        });
+3
source share
2 answers

It seems to work.

$(document).ready(function() {
       $("td.ms-cal-monthitem:has(a[href*='|'])").css("background-color", "#ffff99");
       $("td.ms-cal-monthitem:has(a[href]):not(:has(a[href*='|']))").css("background-color", "#ffcc33");  
}); 
+2
source

, , jquery? , ?

0

Source: https://habr.com/ru/post/1710085/


All Articles