jQuery

jQuery Intro

jQuery Intro Quiz

jQuery Intro Exercise

jQuery Basic

jQuery Basic Quiz

jQuery Basic Exercise

jQuery Advance

jQuery Advance Quiz

jQuery Advance Exercise

jQuery Selectors

jQuery Effects

jQuery Events

jQuery Methods and Properties

jQuery Traversing

jQuery CSS and HTML Methods

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:-

 

  1. Its syntax for returning text content is:- $(selector).text()
  2. Its syntax for setting text content is:- $(selector).text(content)
  3. 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
  • index - Returns the index position of the element in the set
  • currentcontent - Returns current content of selected elements

Code Explanation

All Tutorials related to jQuery CSS and HTML Methods

All Sections related to jQuery