Reputation: 2149
Im using Jquery datepicker and also a PhP calender in my webpage. I want to use the same javascript array as in the datepicker function in my PHP calender to change the class of the "not available" dates. jquery contains works fine for a single date, but is it possible to do the same with an array?
Code that works (1 value):
$("td:contains('21')").css("color", "red");
The ideal situation is to do the same for all TD with an array, something like:
var unavailableDates1 = ["21","23","25"];
$("td:contains(unavailableDates1)").css("color", "red");
help!
Upvotes: 0
Views: 1453
Reputation: 1485
$('td:contains("21"), td:contains("22"), td:contains("23")').css("color", "red");
Upvotes: 0
Reputation: 18022
You can loop an array like this:
var unavailableDates1 = ["21","23","25"];
for(var i=0;i<unavailableDate1.length;i++){
$("td:contains("+unavailableDates1[i]+")").css("color", "red");
}
Upvotes: 2