How to start jquery datepicker with focus -


i'm new jquery , start datepicker focus.

my first textbox date field , have tried give box focus javascript datepicker won't come unless click somewhere else on page , give focus clicking inside box.

is there way start datepicker focus , maybe have widget start when page loads drop focus when user leaves box?

  $( "#date" ).datepicker({     dateformat: "mm-dd-yy"   }); 

try - http://www.jsfiddle.net/wnuwq/embedded/result

$(document).ready(function() {     $("#datepick").datepicker({         dateformat: "mm-dd-yy"     });     $("#datepick").focus(function() {         $("#datepick").datepicker("show");     });     $("#datepick").focus(); }); 

edit: .ready() function of $(document) object fired when dom loaded in browser. first attach datepicker input, , attach focus eventhandler shows datepicker , last set focus on input.

this chained 1 line in:

$(document).ready(function() {     $("#datepick").datepicker({         dateformat: "mm-dd-yy"     }).focus(function() {         $("#datepick").datepicker("show");     }).focus(); }); 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -