91-9990449935 0120-4256464 |
jQuery prop()jQuery prop() method is used for two purpose.
The jQuery prop() method is generally used to retrieve property values i.e. DOM properties (like tagName, nodeName, defaultChecked) or own custom made properties. This is a very convenient way to set the values of properties, especially the multiple properties. If you want to retrieve HTML attributes, you should use the attr() method instead. The removeProp() method is used to remove a property.Syntax: To return the value of a property: To set the property and value: To set property and value by using a function: To set multiple properties and values: Parameters of jQuery prop() method
Example of jQuery prop() methodLet's see a simple example of jQuery prop() method. Test it NowjQuery prop() example 2Let's see another example of jQuery prop() method. Test it NowDifference between jQuery attr() and jQuery prop() method:This is a very common question because most of the people are confused about where to use prop() method and where attr() method. The differences between them are very important in specific situation. Following is the exact differences between them:
Next TopicjQuery offset()
|