Get value from input

I am very new to jQuery, so this might be a dumb question. I am using jQuery datepicker and I am trying to extract a date from input in a simple <div> .

The page works as follows:

  • You select a date using jQuery datepicker.
  • You pick time using jQuery timepicker.
  • You select a place with a normal selection field.
  • A text will appear, and you must confirm the date, time and place.

I have a problem getting values ​​from inputs.

When I use this script, nothing happens:

 $("input").keyup(function () { var value = $(this).val(); $("#datum").text(value); }).keyup(); 

I have a div with id="datum" where I want to display the results.

My datpike code is as follows:

 $('#datepicker').datepicker( { onSelect: function(date) { $("#pick_time").show(); // Go to step 2 }, showWeek: true, firstDay: 1 }); 
+1
source share
1 answer

Do not use the keyup function for $('input') . Use .blur() .

 $("input").blur(function() { var value = $(this).val(); $("#datnum").text(value); }); 
0
source

Source: https://habr.com/ru/post/1388137/


All Articles