Tags
Asked 3 years ago
10 Jun 2021
Views 430
Winifred

Winifred posted

How to extract text from all elements of given class by jQuery


<div class="answer">A</div>
<div class="answer">B</div>
<div class="answer">C</div>
<div class="answer">D</div>


how to use text() in jQuery for getting all text by the class name ?
jessica

jessica
answered Jun 10 '21 00:00

get all text by following code :

 
$(".answer").each(function(){
var text=$(this).text();
console.log(text)
});

Post Answer