0

If I click add button then the same for will added next to the previous. I wan to get the values of input fields of each forms using each() function. I tried running below code.

$('.question-div').each(function(i) {
    //to get Degree field value.  
    console.log($(".question_Degree_0").val());                      
 });

The problem is like this way I only get two times the same value of the first form's Degree value. For example if I select 1 in first form, and if I add one more form, the second time also get the value '1' in Degree value though I select different value.. My question is what can I do so that I can get values of input fields using each() function?
Thank you.

1
  • Just try console.log($(".question_Degree_0", this).val()); Commented Jul 11, 2016 at 6:09

3 Answers 3

2

Try using

$(".question_Degree_0", this).val()

inside your loop function.

or

$('.question-div .question_Degree_0').each(function(i) {
    console.log($(this).val());                        
});
Sign up to request clarification or add additional context in comments.

2 Comments

@DharaParmar – I did not answer but did comment about this as I am not 100% sure about the markup and the context of the question.. If the person who answered is, he is free to answer.. ;)
@Rayon ok then +1 for him ;)
0

Try this,

$('input').each(function(i) {

     console.log($(this).val());//to get all the input value.                        
 });

Comments

0

I have executed the piece of code and the solution is as below

$('input').each(function(ele) { console.log($(this).val()); });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.