jQuery text() Method
jQuery text() Method
The text() method is used to set or return the text content of the selected elements.
For your Information:-
- When it is used to set content, it will overwrite the content of ALL matched elements.
- When it is used to return content, it will return the text content of all matched elements with their tags removed.
Syntax:-
- Its syntax for returning text content is:- $(selector).text()
- Its syntax for setting text content is:- $(selector).text(content)
- Its syntax for setting text bu function is:- $(selector).text(function(index,currentcontent))
Further Explanation:-
Parameter | Description |
---|---|
content | Required. Specifies the new text content for the selected elements |
function(index,currentcontent) | Optional. Specifies a function that returns the new text content for the selected elements
|
Code Explanation
All Tutorials related to jQuery CSS and HTML Methods
addClass() Method in jQuery
after() Method in jQuery
append() Method in jQuery
appendTo() Method in jQuery
attr() Method in jQuery
before() Method in jQuery
clone() Method in jQuery
css() Method in jQuery
detach() Method in jQuery
empty() Method in jQuery
hasClass() Method in jQuery
height() Method in jQuery
html() Method in jQuery
innerHeight() Method in jQuery
innerWidth() Method in jQuery
insertAfter() Method in jQuery
insertBefore() Method in jQuery
offset() Method in jQuery
offsetParent() Method in jQuery
outerHeight() Method in jQuery
outerWidth() Method in jQuery
position() Method in jQuery
prepend() Method in jQuery
prependTo() Method in jQuery
prop() Method in jQuery
remove() Method in jQuery
removeAttr() Method in jQuery
removeClass() Method in jQuery
removeProp() Method in jQuery
replaceAll() Method in jQuery
replaceWith() Method in jQuery
scrollLeft() Method in jQuery
scrollTop() Method in jQuery
text() Method in jQuery
toggleClass() Method in jQuery
unwrap() Method in jQuery
val() Method in jQuery
width() Method in jQuery
wrap() Method in jQuery
wrapAll() Method in jQuery
wrapInner() Method in jQuery