change event doesn’t work with span tag using jquery

  ajax, jquery-mobile, laravel

I have the following input :

  <div class="input-group date">
      <input type="text" class="form-control" id="casting_date_naissance" name="casting_date_naissance">
      <span class="input-group-text input-group-append input-group-addon" id="spanEstPaymentDate">
        <i class="simple-icon-calendar"></i>
      </span> 
  </div>

And this script :

 var dateinput = document.getElementById("casting_date_naissance");
dateinput.addEventListener('change', function(evt) {
  alert('a');
  console.log(dateinput);
});

Why when I execute this script the change event doesn’t fire, and when I remove the

<span class="input-group-text input-group-append input-group-addon" id="spanEstPaymentDate">
            <i class="simple-icon-calendar"></i>
          </span>

from the Html, the change event does fire.

Source: Laravel

Leave a Reply