jQuery UI Datepicker set display month -


i need set display month on datepicker in click event of control. possible? can't use setdate method since set specific date, whereas i'm trying emulate prev/next month buttons on datepicker.

edit: i'm using inline datepicker https://jqueryui.com/datepicker/#inline

html:

<input type="button" onclick="changemonth(1);" /> 

javascript:

function changemonth(month) {     //set month on datepicker     $("#datepicker").??? } 

assuming have mm/dd/yyyy mask, like in demo this:

upd2. using datepicker api

function changemonth(month) {    var initialval = $('#datepicker').datepicker('getdate')    curmonth = date.getmonth(),     if(month > 0 && curmonth < 12){       initialval.setmonth(curmonth + 1)    }     if(month < 0 && curmonth > 1) {       initialval.setmonth(curmonth - 1)    }    $('#datepicker').datepicker('setdate', initialval); } 

the calling changemonth(1) or changemonth(-1) should change date in datapicker field.

upd1. if you're using inlined version

you can "click" buttons jquery click event:

$('#datepicker .ui-datepicker-prev').click() // month $('#datepicker .ui-datepicker-next').click() //month forward 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -