Javascript Ajax jQuery Html PHP Example Quiz New MORE
Need a Website Or Web Application.Contact : +91 9437911966 (Whatsapp) Note: Paid Service

jQuery text() method With Example

To get or set text content for a selected element in jQuery html() method is used. It is an inbuilt method of jQuery.




<!DOCTYPE html>
<script src=""></script>
    $("div").text("I am Set in this div element.");
    var data=$("div").text();
<button id="set_button">Set the content</button>
<div id="div1" style="width:200px;height:80px;background-color:palegreen;">html() method jQuery</div><br>
<button id="get_button">Get the content</button>
<p>By click on the get the content button you can get the data of the div element</p>
Run it Yourself »

Difference between text() and html() method:

To get or set only text content we used text() method
To get text with html markup we used html() method.