Wednesday, 1 April 2015

Difference b/w attr() and prop() /



An input field can have the attribute "value". This will equal the default value you entered. If the user changes the value in the input field, the property "value" changes in the DOM Tree, but the original attribute is left remaining.

So basically, if you want the default value setup for an HTML tag's attribute, use the .attr() function. If you that value can be changed by the user (such as inputs, checkbox's, radios, etc.) use the .prop() function to get the newest value.

No comments:

Post a Comment