How to get text contents of all matched elements using jQuery ? Last Updated : 05 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to get the text content of all matched class elements using jQuery. To get the text content, we use the text() method, which helps to set or return the text content of the element. Syntax: $('Selector').text();Approach 1: We create a div element that contains multiple div's with class "content", then we use the jQuery text() method on the "content" class, to get all text content of that particular class. Example: In this example, we will display all contents of the matched class elements. HTML <!DOCTYPE> <html> <head> <title> How to get text contents of all matched elements using jQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> </head> <body> <h1 style="color:green;"> GeeksforGeeks </h1> <h3> How to get text contents of all <br>matched elements using jQuery? </h3> <div class="contents"> <div class="content">Welcome</div> <div class="content">GeeksforGeeks</div> <div class="content">Web Development</div> <div class="content">HTML</div> <div class="content">CSS</div> </div> <script> // Select all elements content wit class "content" let cont = $('.content').text(); // Display the text contents to the console console.log(cont); </script> </body> </html> Output: Approach 2: First, we will create a div element, that contains multiple div's with the class "content" and then we use each() method on the "content" class to display the text content. Example 2: In this example, we will display all contents of the matched class elements. HTML <!DOCTYPE> <html> <head> <title> How to get text contents of all matched elements using jQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <h3> How to get text contents of all <br>matched elements using jQuery? </h3> <div class="contents"> <div class="content">Welcome</div> <div class="content">GeeksforGeeks</div> <div class="content">Web Development</div> <div class="content">HTML</div> <div class="content">CSS</div> </div> <script> let cont = $('.content'); cont.each(function () { let textCont = $(this).text(); console.log(textCont); }); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to filter the children of any element using jQuery ? B blalverma92 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads How to make first word bold of all elements using jQuery ? In this article, we will make first word bold of all elements using jquery. To make the first word bold, we use html(), and text() methods. html() Method: The html() method in jQuery is used to set or return the innerHTML content of the selected element. Syntax: It sets the content of matched elemen 1 min read How to get the outer html of an element using jQuery ? Sometimes, there is a need to get the entire HTML element by its id and not merely its contents, for doing so, we shall use the HTML DOM outerHTML Property to get the outer HTML of HTML element. Syntax: document.getElementById("your-element-id").outerHTML) You can use a variable and initialize it to 2 min read How to filter the children of any element using jQuery ? In this article we will learn how to filter the children of any element in JQuery. JQuery is a fast and lightweight JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript. It is widely famous for its motto o 3 min read How to select all sibling elements of an element using jQuery ? In this article, we will discuss how to select all sibling elements of an element using jQuery. To select all sibling elements of an element, we will use the siblings() method. The siblings() method is used to find all sibling elements of the selected element. The siblings are those having the same 2 min read How to find an element by text using jQuery ? We will learn how to find an element using jQuery's API. This article requires some knowledge of HTML, CSS, JavaScript, Bootstrap, and jQuery. The elements can be selected based on whether they contain the string we want to find. This can be done using the jQuery contains selector to select elements 2 min read How to display the tag name of the clicked element using jQuery ? Given a HTML document containing some elements and the task is to display the clicked element. Approach: First we create a HTML document containing some elements and add a jQuery function to display the clicked element. We select the HTML body using jQuery selector and when user click the element th 1 min read Like