jquery datepicker is always visible

Asked

Viewed 377 times

0

I’m trying to use jquery datepicker, but every time I create it it keeps popping up, as if it’s there statically. Example of what is happening, and not just appearing when I click. https://jsfiddle.net/3hcuLf0j/

  • You are using span. I made a change: https://jsfiddle.net/3hcuLf0j/5/

2 answers

0

Edited/corrected: I forgot to edit the fiddle link.

Maybe using an input instead of the span tag will work. example: https://jsfiddle.net/3hcuLf0j/6/

html:

<input type="text" id="test" maxlenght="10">

js:

$("#test").datepicker();
  • Thanks for the answer. It is that I had to use in a span even. Will not have to create events to close?

  • Check out this fiddle: https://jsfiddle.net/3hcuLf0j/10/ I took this link reference: https://stackoverflow.com/questions/1112035/open-jquery-datepicker-by-clicking-on-an-image-w-no-inputfield/1112135#1112135

0

As Diego Andrade pointed me, if I use an input everything happens correctly. So I solved the situation as follows https://jsfiddle.net/3hcuLf0j/9/

I have an input inside span, I’ll keep that input hidden

<span id="test">
   <input id="datepicker" type="text">
   bla
</span>

And I will use the following javascript chat

$("#datepicker").datepicker();
$("#datepicker").hide();

$("#test").click(function(){
    $("#datepicker").show().focus().hide();
});

Every time span is clicked, datepicker will open

Browser other questions tagged

You are not signed in. Login or sign up in order to post.