JQuery 1.6 prop () in div header

Possible duplicates:
.prop () vs .attr ()

What is the difference between execution

$('div').prop('title','whatever'); //set
$('div').prop('title'); //get

and

$('div').attr('title','whatever'); //set
$('div').attr('title'); //get

prop()seems to behave the same as attr()in the case of the div attribute. I read the 1.6 documentation for this, but I'm still a bit confused.

THIS IS NOT EXACTLY DUPLICATE .prop () vs .attr () . This message does not answer the question. Please do not close it.

+3
source share
1 answer

propand attrdo not always give different results. They give only different results when there is a difference between a property and an attribute.

For example, with the checked/ property attribute :

$(':checkbox').prop('checked'); // returns boolean true false
$(':checkbox').attr('checked'); // returns string "checked" or undefined

This is well explained in vs . propattr

, title/property, . , .

+5

All Articles