HTML DOM setAttribute() ·½·¨
ʵÀý
ÉèÖà input ÔªËØµÄ type ÊôÐÔ£º
document.getElementsByTagName("INPUT")[0].setAttribute("type","button");
ÉèÖøÃÊôÐÔ֮ǰ£º
ÉèÖøÃÊôÐÔÖ®ºó£º
¶¨ÒåºÍÓ÷¨
setAttribute() ·½·¨Ìí¼ÓÖ¸¶¨µÄÊôÐÔ£¬²¢ÎªÆä¸³Ö¸¶¨µÄÖµ¡£
Èç¹ûÕâ¸öÖ¸¶¨µÄÊôÐÔÒÑ´æÔÚ£¬Ôò½öÉèÖÃ/¸ü¸ÄÖµ¡£
ä¯ÀÀÆ÷Ö§³Ö
IE | Firefox | Chrome | Safari | Opera |
---|---|---|---|---|
ËùÓÐÖ÷Á÷ä¯ÀÀÆ÷¾ùÖ§³Ö setAttribute() ·½·¨¡£
×¢ÊÍ£ºInternet Explorer 8 ÒÔ¼°¸üÔçµÄ°æ±¾²»Ö§³Ö´Ë·½·¨¡£
Óï·¨
element.setAttribute(attributename,attributevalue)
²ÎÊý
²ÎÊý | ÀàÐÍ | ÃèÊö |
---|---|---|
attributename | String | ±ØÐè¡£ÄúÏ£ÍûÌí¼ÓµÄÊôÐÔµÄÃû³Æ¡£ |
attributevalue | String | ±ØÐè¡£ÄúÏ£ÍûÌí¼ÓµÄÊôÐÔÖµ¡£ |
·µ»ØÖµ
ÎÞ·µ»ØÖµ¡£
¼¼Êõϸ½Ú
DOM °æ±¾ | Core Level 1 Element Object |