How to use HTML Text Method in JQuery
This article describe about HTML Text Method in JQuery.
HTML text() method in jQuery
-
text() method sets the text content of selected elements.
-
text() method is used to return a value,
-
text() method returns combination of the text content of all matched element.
Syntax
Example
Following is an example show to use of .text(val) methods. this method sets value of the object
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function ()
{
$("button").click(function ()
{
alert($("p").text());
});
});
</script>
</head>
<body>
<p>This is a JQuery.</p>
<p>This is a .Netheaven.</p>
<button>Text of all p elements</button>
</body>
</html>
|
Output1

Output2

Using a Function
text() method using function to set the text content of all selected elements.
Syntax
$(selector).text(function(index,oldcontent))
|
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here