• Resolved David Sword

    (@davidsword)


    If I have a button that creates input’s like so:

    jQuery('button').click(function(){
            jQuery('div').html("<input />")
        })
    
        jQuery('input').change(function(){
            alert('change!')
        })

    Why doesn’t jQuery recognize the newly made inputs with $('input').change() ? how do I get around this? Do I have to push the new inputs into jQuery’s recognition or something?

    Here’s a jsfiddle w/ the problem: https://jsfiddle.net/Ltkfj3g9/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter David Sword

    (@davidsword)

    gah of course i find the answer after 2 hours of trying immediately after I finally seek help.

    needed to bind it to a parent (whatever that means)

    jQuery(document).on('change', 'input', function() {
        alert('change!')
    })
    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    You get cookies for coming back and telling people HOW you solved it! YAY!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘jQuery – make .change() work on dynamic input’s’ is closed to new replies.