Setting the value of HTML5 input type=week thru jquery
问题 How to set the default value of HTML5's input type="week" in Javascript/Jquery? I'm using moment.js to make things easier. HTML <input type="week" id="weekpicker" /> Javascript $('#weekpicker').val(moment().format('YYYY-MM-DD')); The code above doesn't work. 回答1: Here's how I did it (using momentjs): http://momentjs.com/docs/#/get-set/ $('#weekpicker').val(moment().weekYear() + "-W" + moment().week()); First I get the weekYear (not the year, Because the first day of the first week does not