Jquery does not work with the input loaded with Ajax

-1

The jQuery function works normally but by including input ajax jQuery does not work for the input that has been included!

I have the function:

$('.alerta').on('input', function() { 
    alert('Olá mundo!'); 
})

I have input 1 working with the function above:

<div>
    Número 1:<br>
    <input class="alerta" type="text" name="x"/><br><br>
</div>
<div class="div">
</div>

I have ajax that includes input number 2 in classe="div" , but that does not work with the jQuery function.

<?php
echo 'Número 2:<br>
<input class="alerta" type="text" name="y"/><br><br>';
?>
    
asked by anonymous 10.11.2017 / 22:57

1 answer

0

Did you try to put it like this?

$('body').on('click', '#botao', function (e) {
   alert('teste');
}); 
    
10.11.2017 / 23:04