.text( [ text_String ] )
Gets the innerText / TextContent of an element. Sets the innerText / TextContent of an element if Text string is provided and returns the new innerText.
Parameters
Returns
Example 1
Gets innerText of #cont div.
JS
HTML
$.domLoaded(function() { $.get("#get").on("click", function() { // get the innerText of #cont var co = $.get("#cont").text(); alert(co); }); });
Result
Example 2
Sets innerText of #cont div.
JS
HTML
$.domLoaded(function() { $.get("#get").on("click", function() { // set innerText of #cont $.get("#cont").text("Welcome, Please See the demos"); }); });
Result
| |||||||||||||||