I am trying to make a dynamic function but i am having trouble because i cant seem to run my JQuery code inside of a JS function. I have a working example here.
I have a second example here. the only difference between the two JsFiddle’s is that i switched the call function from:
$('#btnAdd').click(function() {
to this calling function:
function addBtn(){
and the same on the delBtn. the reason i want to do this is so i can pass an argument so i know if i want to add another question field or an answer field.
jsFiddle wraps the JavaScript code inside a closure by default (i.e. the functions are private variables). You have to choose “no wrap (body)”: http://jsfiddle.net/UpEvK/2/.