I have a form full generated with DOM. In that form, I have a button with the class "more-fields" and after clicking on this button I would like to show other hidden fields. But my script is not working without alert()
. What am I doing wrong?
$(function() {
$(".more-fields").on("click", function(){
$(".other-fields").show();
});
});
This is not working. But when i add alert() before click, than it is working:
$(function() {
alert("xxx");
$(".more-fields").on("click", function(){
$(".other-fields").show();
});
});
Why it is not working without alert?
Solution:
$(function() {
$(document).on('click', '.more-fields', function() {
$(".other-fields").show();
});
});