1.6
http://blog.darkthread.net/post-2011-05-05-jquery-1-6-notes.aspx
http://blog.xuite.net/vexed/tech/44905647
http://mzhou.me/?p=95416
1.6.1
http://blog.darkthread.net/post-2011-05-13-jquery-1-6-1.aspx
http://blog.jquery.com/2011/05/12/jquery-1-6-1-released/
However, once jQuery 1.6 was released, the jQuery team understood that it was not particularly useful to set something that the browser was only concerned with on page load. Therefore, in the interest of backwards compatibility and the usefulness of the
.attr()
method, we will continue to be able to get and set these boolean attributes with the .attr()
method in jQuery 1.6.1.The most common boolean attributes are checked, selected, disabled, and readOnly, but here is a full list of boolean attributes/properties that jQuery 1.6.1 supports dynamically getting and setting with
.attr()
:autofocus, autoplay, async, checked, controls, defer, disabled, hidden, loop, multiple, open, readonly, required, scoped, selected
It is still recommended that
.prop()
be used when setting these boolean attributes/properties, but your code will continue working in jQuery 1.6.1 even if these use cases are not switched to use the .prop()
method.Below is a list of some attributes and properties and which method should normally be used when getting or setting them. This is the preferred usage, but the
.attr()
method will work in all attribute cases.Note that some DOM Element properties are also listed below – but will only work with the new
.prop()
method.Attribute/Property | .attr() | .prop() |
---|---|---|
accesskey | ✓ | |
align | ✓ | |
async | ✓ | ✓ |
autofocus | ✓ | ✓ |
checked | ✓ | ✓ |
class | ✓ | |
contenteditable | ✓ | |
defaultValue | ✓ | |
draggable | ✓ | |
href | ✓ | |
id | ✓ | |
label | ✓ | |
location * | ✓ | ✓ |
multiple | ✓ | ✓ |
nodeName | ✓ | |
nodeType | ✓ | |
readOnly | ✓ | ✓ |
rel | ✓ | |
selected | ✓ | ✓ |
selectedIndex | ✓ | |
src | ✓ | |
style | ✓ | |
tabindex | ✓ | |
tagName | ✓ | |
title | ✓ | |
type | ✓ | |
width ** | ✓ |
沒有留言:
張貼留言