Sigh. I know many things. Javascript is not one of them. :)
I'm trying to use some of the example code from the BPL to help me with a form. I need to iterate through this table, when it is created and each time a row is added (I think - unless there is a more efficient way) and set and attribute on a field.
What I've tinkered with is almost working - it just makes the attribute change when there are changes on a row instead of doing it when the table/rows are first created.
1. what am I doing wrong? I just want to set that .attr upfront for all rows
2. where is the best reference for all of the attributes?
Thanks in advance
$(document).ready(function(){ $('.trips').on('change', function() { $('.trips tbody tr').each(function() { var todaysDate = new Date(); // Gets today's date // Max date attribute is in "YYYY-MM-DD". Need to format today's date accordingly var year = todaysDate.getFullYear(); // YYYY var month = ("0" + (todaysDate.getMonth() + 1)).slice(-2); // MM var day = ("0" + todaysDate.getDate()).slice(-2); // DD var minDate = (year +"-"+ month +"-"+ day); // Results in "YYYY-MM-DD" for today's date // Now to set the max date value for the calendar to be today's date $(this).find('.travel_date input').attr('min',minDate); }); }); });