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

after() and before() in jQuery

after() and before() Methods

 

 

after() and before() are similar to append() and before() methods but the difference is that the latter adds content to the current element while the first two insert contents after or before the current elements.

 

after():-

 

after() inserts content after the selected elements.

 

Syntax:-

 

Its syntax is:- $(selector).after(content, function(index))

 

Further Explanation:-

 

Parameter Description
content Required. Specifies the content to insert.
function(index) Specifies a function that returns the content to insert
  • index - Returns the index position of the element in the set

 

before():-

 

before() inserts content before the selected elements.

 

Syntax:-

 

Its syntax is:-$(selector).before(content, function(index))

 

Return:-

 

Parameter Description
content Specifies the content to insert.
function(index) Optional. Specifies a function that returns the content to insert
  • index - Returns the index position of the element in the set

Code Explanation

All Tutorials related to jQuery Basic

All Sections related to jQuery