View Full Version : jquery help, hide and get day month name

11-17-2009, 12:26 PM
Hi there

How can I use Jquery to change the span text to the current month name and hide the tr if its after the 15th of the month?

<tr class = "hideIfDayOfMonthAfter15">
<td class="flag" ><span class="month"> December</span> </td>

11-17-2009, 03:35 PM
If you're looking for a pure jquery/javascript solution, the date would always depend upon the client system. A much better way to handle this would be to use your server-side language to determine which rows to display. Then your always sure the date is what you expect.

For javascript, the current date (of the client system) relies on new Date(). The first answer to this post (http://stackoverflow.com/questions/233553/how-do-i-pre-populate-a-jquery-datepicker-textbox-with-todays-date) shows how to fetch the current date by parts. That would take care of the span month. To hide the tr, you could test the current day value and hide/show based on that.