I am doing a project with fullcalendar and I need to be able to select an element based on the day number. Here is a sample of the element I need to select:
<div class="fc-day-number">1</div>
Here is the javascript I have written:
$("div.fc-day-number:contains(" + day + ")").parent().parent().css({ 'background-color': 'Green' });
This will grab all the divs whose inner text contains the day variable, problem is if day==1 then it also selects 11,12,13,21,31,etc. How do I write a JQuery selector that will grab the divs with class "fc-day-number" and whose inner text is exactly equal to day?
Write your own filter
function:
$("div.fc-day-number").filter(function (){
return $(this).text() == day;
}).parent().parent().css({ 'background-color': 'Green' });
$("div.fc-day-number").each(function (){
if($(this).text()==day)
{
$(this).css({ 'background-color': 'Green' });
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With