I'm able to get all elements with the same class name with... convInputs=$('body').find('.convertUnits')
I iterate it like this to get the values...
$.each(convInputs, function(index, item){
alert(item.value);
});
But when it's a div it gives me undefined... I tried item.text
which doesn't work either.
How do I get the value of the div?
CodePudding user response:
Try with textContent
:
$.each($('.test'), function(index, item){
console.log(item.value ' using value.');
console.log(item.text ' using text.');
console.log(item.textContent ' using textContent.');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div >ABC</div>