In jQuery three very important and useful methods for DOM(Document Object Model) manipulations.
.text() – Sets or get the text content of selected elements.
.html() – Sets or get the content of selected elements (including HTML markup content).
.val() – Sets or get the value of all form fields(input,checkbox,radio,select,textarea).
Examples for text():
<span id=”test”>hello world</span>
var output= $(“#test”).text();
alert(output); //hello world
<span id=”test”>hello world</span>
var output= $(“#test”).text(“hello india”);
above jQuery code line will replace hello world to hello india.
Examples for html():
Examples for val():