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 prop() Method

jQuery prop() Method

 

 

The prop() method is used to set or return properties and values of the selected elements.

 

For your Information:-

 

  • When it is used to set property values, it will set one or more property/value pairs for the set of matched elements.
  • When it is used to return the property value, it will only return the value of the FIRST matched element.

 

Syntax:-

 

  1. Its syntax for returning value of Property is:- $(selector).prop(property)
  2. Its syntax for setting Property and Value is:- $(selector).prop(property,value)
  3. Its syntax for setting multiple Properties and Values is:- $(selector).prop({property:value, property:value,...})
  4. Its syntax for setting Property and Value by function is:- $(selector).prop(property,function(index,currentvalue))

 

Further Explanation:-

 

Parameter Description
property Specifies the name of the property
value Specifies the value of the property
function(index,currentvalue) Specifies a function that returns the property value to set
  • index - Receives the index position of the element in the set
  • currentvalue - Receives the current property value of selected elements

Code Explanation

All Tutorials related to jQuery CSS and HTML Methods

All Sections related to jQuery