×ðÁú¿­Ê±¹ÙÍøµÇ¼

jsÖÐÔõôÒƳýµã»÷ÊÂÎñ

javascript ÖÐÒƳýµã»÷ÊÂÎñÓÐÁ½ÖÖÒªÁ죺ÒƳýʹÓà onclick ÊôÐÔÌí¼ÓµÄÄÚÁªµã»÷ÊÂÎñ £¬ÐèʹÓà removeattribute() ÒªÁ죻ÒƳýʹÓà addeventlistener() ÒªÁìÌí¼ÓµÄÊÂÎñÕìÌýÆ÷ £¬ÐèʹÓà removeeventlistener() ÒªÁì £¬È·±£Ê¹ÓÃÓëÌí¼ÓʱÏàͬµÄÊÂÎñÀàÐͺʹ¦Àíº¯ÊýÃû³Æ¡£

ÔõÑùÒƳý JavaScript Öеĵã»÷ÊÂÎñ

ÒƳýÄÚÁªµã»÷ÊÂÎñ

ÒªÒƳýʹÓà onclick ÊôÐÔÌí¼ÓµÄÄÚÁªµã»÷ÊÂÎñ £¬¿ÉÒÔʹÓà removeAttribute() ÒªÁ죺

element.removeAttribute("onclick");

µÇ¼ºó¸´ÖÆ

ÒƳýÊÂÎñÕìÌýÆ÷

ÒªÒƳýʹÓà addEventListener() ÒªÁìÌí¼ÓµÄÊÂÎñÕìÌýÆ÷ £¬¿ÉÒÔʹÓà removeEventListener() ÒªÁ죺

element.removeEventListener("click", myFunction);

µÇ¼ºó¸´ÖÆ

×¢ÖØ£º È·±£Ê¹ÓÃÓëÌí¼ÓÊÂÎñÕìÌýÆ÷ʱÏàͬµÄÊÂÎñÀàÐͺʹ¦Àíº¯ÊýÃû³Æ¡£

ÏêϸʾÀý

¼ÙÉèÄúÓÐÒ»¸ö°´Å¥ £¬ÆäÄÚÁªµã»÷ÊÂÎñ´¥·¢Ò»¸öÃûΪ myFunction µÄº¯Êý£º

<button onclick="myFunction()">µã»÷ÎÒ</button>

µÇ¼ºó¸´ÖÆ

ÒªÒƳý´Ëµã»÷ÊÂÎñ £¬Äú¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

const button = document.querySelector("button");
button.removeAttribute("onclick");

µÇ¼ºó¸´ÖÆ

ÒªÒƳýʹÓà addEventListener() ÒªÁìÌí¼ÓµÄµã»÷ÊÂÎñ £¬Äú¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

const button = document.querySelector("button");
button.removeEventListener("click", myFunction);

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇjsÖÐÔõôÒƳýµã»÷ÊÂÎñµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ