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

Content Manipluation

Content Manipulation

 

 

jQuery allows content Manipulation. The methods used for these purposes are html() and text(). When we do not pass parameters in them, they will simply return the content i.e, we will get content. When the content is passed in them as a parameter it will replace it with the original content i.e, the content will be set or changed or replaced.

 

html():-

 

html() will set and get the content in the form of HTML which includes both contents and tags.

 

Syntax:-

 

Its syntax is:- $(selector).html(content) OR $(selector).html(function(index, currentcontent))

 

Further Explanation:-

 

Parameter Description
content Required. Specifies the new content for the selected elements.
function(index,currentcontent) Optional. Specifies a function that returns the new content for the selected elements
  • index - Returns the index position of the element in the set
  • currentcontent - Returns the current HTML content of the selected element

 

text():-

 

text() will only set and get the content in the form of HTML content and tags will be changed into normal text/content.

 

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 Basic

All Sections related to jQuery