Marc Sommerson
Marc Sommerson

Reputation: 99

Jquery, tranfer value on click

I use this code to transfer value which is inputed in input box to span:

$(function()  {
     $(".single-product p:nth-child(5) input").keyup(function () {
  $('#birthdate').html($(this).val());
});
 });

and it works but when I use it with another function which I made for a jquery datepicker (calendar)

 $(function() {
        $( ".single-product p:nth-child(5) input" ).datepicker();
      });

It does not transfer value to a span until I press enter. How can I change this to be automatic? (As soon as a user picks the date it goes to input (currently works) and then to span.

Upvotes: 0

Views: 37

Answers (1)

Manwal
Manwal

Reputation: 23816

Try using onSelect() event of datepicker

$( ".single-product p:nth-child(5) input" ).datepicker({
      onSelect: function (dateText, inst) {
         //set value to another input
      }
   });

Upvotes: 1

Related Questions