Sunday, July 28, 2013

jquery - .prop() vs .attr()

http://api.jquery.com/prop/
http://stackoverflow.com/questions/5874652/prop-vs-attr/5884994#5884994
A DOM element is an object, a thing in memory. Like most objects in OOP, it has properties. It also, separately, has a map of the attributes defined on the element (usually coming from the markup that the browser read to create the element). Some of the element's properties get their initial values fromattributes with the same or similar names (value gets its initial value from the "value" attribute; hrefgets its initial value from the "href" attribute, but it's not exactly the same value; className from the "class" attribute). Other properties get their initial values in other ways: For instance, the parentNodeproperty gets its value based on what its parent element is; an element always has a style property, whether it has a "style" attribute or not.


No comments:

Post a Comment

Followers

Blog Archive