0

In my code there is a div with id="mix" generated dynamically with the jQuery load() method:

$('#mix').load('handlers/muscript.php');

muscript.php contains a few input element, which will be loaded into this div having id "mix" .

the event keyup is not firing when the user enters their text.

The code for creating the new input elements is:

$('#add').click(function() {
    $('<input id="'+k+'" type="text" name="trans' + k + '"  />')
      .appendTo('#mix');

The code for capturing the user's values is:

$('input').keyup(function() {
    handler = $(this).val();
    name = $(this).attr('name');

This second code block work for the single element, but it is not fired for dynamically generated elements.

1 Answers1

4

Try changing the event handler from

$('input').keyup(function() {

to

$('#mix').on('keyup','input' function() {
depperm
  • 10,606
  • 4
  • 43
  • 67