I'm creating an app to build your own form with JQuery. I want to add more options on the checkbox and the radio tipe questions. For some reason the last function isn't working. It's meant to add a new option when clicking on the button created in the first function.
//Adding a checkbox question
$("#btn1").click( function(){
$("#rectangle").before("<br><input type='text'placeholder='Question'> <input type='checkbox'> <input type='text' placeholder='Opção'> <button class='btn newCheck'>+</button>");
});
//Adding a new option
$(".newCheck").click( function(){
console.log("+ radiobutton");
$(this).before("<input type='checkbox'> <input type='text' placeholder='Option'>");
});
I tried putting " onclick='' " directly on the button and do a normal javascript function and it worked fine. The problem with that is that if I have several checkbox tipe questions new options will only be added to the first question.
Aucun commentaire:
Enregistrer un commentaire