jQuery¼¼Êõ

jQuery ÖÐ attr() ºÍ prop() ·½·¨µÄÇø±ð(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-06-09 10:01 ÎÒÒªÆÀÂÛ( )

1.8.3 ÖÐ boolHook = {get: function( elem, name ) {// Align boolean attributes with corresponding properties// Fall back to attribute presence where some booleans are not supportedvar attrNode,propert

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()£¬¾ßÌå¼ûÏÂ±í£º

×¢£º±¾ÎÄÖеĴ󲿷ֹ۵ãÒÔ¼°Àý×ÓÊôÓÚ¸öÈËÀí½â£¬ÄÑÃ⻹Óв»×¼È·µÄµØ·½£¬»¶Ó­ÓÐÏà¹ØÑо¿µÄͬÐÐÖ¸Õý¡£

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ¡¶jQueryʵս¡·(jQueryʵս)ɨÃè°æ[PDF]

    ¡¶jQueryʵս¡·(jQueryʵս)ɨÃè°æ[PDF]

    2017-06-09 11:00

  • jQuery¼¼ÊõÁ·Ï°Ìâ

    jQuery¼¼ÊõÁ·Ï°Ìâ

    2017-06-09 10:00

  • ¼´¿ÌÌáÉýjQueryÐÔÄܵÄÊ®¸ö¼¼ÇÉ

    ¼´¿ÌÌáÉýjQueryÐÔÄܵÄÊ®¸ö¼¼ÇÉ

    2017-06-08 18:00

  • jQuery Mobile »ù´¡½Ì³Ì

    jQuery Mobile »ù´¡½Ì³Ì

    2017-06-08 17:05

ÍøÓѵãÆÀ
Ï