Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery dynamic event handling

var counter = 0;

$("button").click(function() {
    $("h2").append("<p class='test'>click me " + (++counter) + "</p>")
});

// With on():

$("h2").on("click", "p.test", function(){
    alert($(this).text());
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jquery #dynamic #event #handling
ADD COMMENT
Topic
Name
7+9 =