Here is my html code:
<form method="POST" action="" class="form1">
<input type="submit" name="submit" value="Generate"><br>
<h3>Questions</h3><button class="new_btn">Add New</button><br>
<div class="add_ques">
<span>Question1</span><textarea name="ques1" id="ques1"></textarea><br>
Option1<select class="option" name="opt1" id="opt1">
<option value="1">1</option>
<option value="2">2</option>
</select><br>
</div>
</form>
When add new button is clicked another set of Question and Option fields will be appended to the end. Name and id of that fields will be automatically incremented. For example: name of next question will be ques2. I need to get the values of all the question using jquery. I have tried following code:
jQuery(".form1").submit(function(){
for (var i = 1; i <= counter; i++) {
qus[i] = jQuery('#ques'+i).val();
}
alert(qus);
});
No alert is displayed. And error is shown in the console on line "qus[i] = jQuery('.ques'+i).val();" . Help me to find error in my code