Tags
Asked 2 years ago
10 Jun 2021
Views 236
Cleora

Cleora posted

get the text of all elements in a page by jQuery

fatso

fatso
answered Jun 10 '21 00:00


$("body").text()

will give you all text from the page
but it show all mixed up text so
one can use the p , b , h1 , h2 tags individuall to get text from that element

$("p").each(function(){
$(this).text()
})
$("b").each(function(){
$(this).text()
})

it still not good to list each element like this but you can use this code :

for(i=0;i<=d.length;i++){  $(d[i]).each( function(){  console.log($(this).text());  })  }
Post Answer