0

I have the code where I want to trigger a function on the date value selected to the input box. How can I achieve this using jQuery? Below is my code:

$("input.Degree_date").live('click', function() { 
    $("input.add").attr("hidden", true);
    $("input.delete").attr("hidden", true);
    alert();
});

$(document).on('input', '.Degree_date', function(){
    alert();
}); 
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
S Das
  • 51
  • 5

3 Answers3

0

If you are using a jquery datepicker to select your date it is easy:

$( "#datepicker" ).datepicker(
{    onSelect: function(dateText, inst) {
        alert('this what you looking for?');
    }
});
Jeremy C.
  • 2,405
  • 1
  • 12
  • 28
0

As live is depricated you should use on.

Then I hope you are using datepicker plugin. So when your clickevent is not on the input field. You should use oninput or onchange event handler.

   $("input.Degree_date").on('input', function() { 
        $("input.add").attr("hidden", true);
        $("input.delete").attr("hidden", true);
        alert();
    });
Dinesh Patra
  • 1,125
  • 12
  • 23
0

Input date,

 <input type="date" id="date">

Function to be triggered,

var call = function() {
    console.log('Trigger');
}

Jquery function on input date selection,

 $('#date').on('input', function() {
        call();
 });
Twinkle
  • 111
  • 5