Reputation: 2086
I also tried live(), but not working... please help
Add Question
<script>
$(document).ready(function(){
$(".add_question").click(function(){
$("#questions").append("<div>How are you?<button class=\"add_answer\">Add answer</button></div>");
});
$(".add_answer").click(function(){
alert("working..");
});
});
Upvotes: 0
Views: 2838
Reputation: 1756
Now is working
$(document).on('click', '.add_question', function() {
$("#questions").append("<div>How are you?<button class='add_answer'>Add answer</button></div>");
});
$(document).on('click', '.add_answer', function() {
alert("working..");
});
Upvotes: 0
Reputation: 97672
live
is not available on newer versions of jQuery so if you want to delegate events use on
$("#questions").on("click", ".add_answer", function(){
alert("working..");
});
Upvotes: 2