jquery - Replace CSS after compare today's date in Javascript -


i have block of js code generates date dynamically in table cells.

'<td class="datestyleblue" data="date"><span id = "'  + customers.productid + 'date">' + util.utility( customers.getdate)  + '</span></td>' 

current css

.datestyleblue{     color: blue;     text-align:center;     font-size: 10px; } 

new css style

.datestylered{     color: red;     text-align:center;     font-size: 10px; } 

i want replace current css class new css if date past today.

so here have far,

    var today = new date();      if (customer.getdate < today) {        $(datestyleblue).replacewith(datestylered);         } 

you should removeclass , addclass.

 if (customer.getdate < today) {        $('.datestyleblue').removeclass('datestyleblue').addclass('datestylered');      } 

don't forget use dot ( . ) select class , need string unless it's javascript variable.

edit

you should more specific selector because code above change every elements class datestyleblue


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -