javascript - Datepicker add css day -


i use jquery ui datepicker, color box day according time array. problem want put color on different days without having create css class, adding hexadecimal color. code:

  $('.datepicker').datepicker({         changemonth: true,         changeyear: true,         beforeshowday: function (date) {             var month = date.getmonth()+1;             var day =  date.getdate();              if (month < 10) {                 month = '0' + month;             }              if (day < 10) {                 day = '0' + day;             }              return [true, $.inarray(the_day, tab_days) >= 0 ? "odd" : ''];         }     }); 

css class:

.odd a.ui-state-default {     color:white;     background-color: red;     background: red; } 

this version works every day have same color, that:

      $(this).css("background-color", hexa color); 

one thing convert rgb hex. this

function rgbtohex(r, g, b) {     return "#" + componenttohex(r) + componenttohex(g) + componenttohex(b); }  $(this).css("background-color", rgbtohex(rin,gin,bin)); 

just change input values whatever want.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -