jqueryexample.com jQuery text() example - jqueryexample.com

jQuery text() example by jqueryexample

This tutorial will show you how to retrieving and setting text getting and setting text using jQuery.  jQuery text() function used to replace or set the text contents of all the matched elements.
Example1:<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function(){
$("#divText").text("A dynamically set text");});
</script>
</head>
<body>
<div id="divText"> Text ABC ....</div>
</body>
</html>

Note: The .text() method cannot be used on form inputs or scripts. To set or get the text value of input or textarea elements, use the .val() method.

Did you like this? Share it:

Discussion

No comments yet, be the first.

Leave a Comment