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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -