1.8.3 ÖÐ
boolHook = { get: function( elem, name ) { // Align boolean attributes with corresponding properties // Fall back to attribute presence where some booleans are not supported var attrNode, property = jQuery.prop( elem, name ); return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? name.toLowerCase() : undefined; } }1.9.0 ÖÐ
boolHook = { get: function( elem, name ) { var // Use .prop to determine if this attribute is understood as boolean prop = jQuery.prop( elem, name ), // Fetch it accordingly attr = typeof prop === "boolean" && elem.getAttribute( name ), detail = typeof prop === "boolean" ? getSetInput && getSetAttribute ? attr != null : // oldIE fabricates an empty string for missing boolean attributes // and conflates checked/selected into attroperties ruseDefault.test( name ) ? elem[ jQuery.camelCase( "default-" + name ) ] : !!attr : // fetch an attribute node for properties not recognized as boolean elem.getAttributeNode( name ); return detail && detail.value !== false ? name.toLowerCase() : undefined; } }Óɴ˿ɼû£¬1.9.0 ¿ªÊ¼²»½¨ÒéʹÓà attr() À´¶Ô¾ßÓÐ true ºÍ false Á½¸öÊôÐÔµÄÊôÐÔ½øÐвÙ×÷ÁË¡£
ÄÇôÎÒÃǵĽáÂÛÊÇ£º
¾ßÓÐ true ºÍ false Á½¸öÊôÐÔµÄÊôÐÔ£¬Èç checked, selected »òÕß disabled ʹÓÃprop()£¬ÆäËûµÄʹÓà attr()£¬¾ßÌå¼ûÏÂ±í£º
×¢£º±¾ÎÄÖеĴ󲿷ֹ۵ãÒÔ¼°Àý×ÓÊôÓÚ¸öÈËÀí½â£¬ÄÑÃ⻹Óв»×¼È·µÄµØ·½£¬»¶ÓÓÐÏà¹ØÑо¿µÄͬÐÐÖ¸Õý¡£
¡¡