How to get all values of input type text with a specific class?
I tried this code. But it's not showing the expected answer.
$('input .classname').each(function(){
console.log($(this).val());
});
One way is to assign a class for all your input elements, that way it will not interfere with unwanted input elements.
For example when you don't need to get all the input elements in the DOM
$('.test').each(function(){
console.log($(this).val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class='test' value='wanted data'/>
<input value='unwanted data'/>