JavaScript??????????????e??
???????????? ???????[ 2015/3/12 15:22:22 ] ????????WEB???? ???? Javascript ???? e??
?????????????У??????????????Щ????????????????????????????????????????????????????????????????????
??????js???????????????????????????????????
????element.addEventListener(type??listener[??useCapture]);//IE6~8?????
????element.attachEvent(’on’+type??listener);//IE6~10??IE11?????
????element[’on’+type]=function(){}//?????????
????demo:
????function cb(){console.log(1);}
????element.addEventListener('click'??cb??false);
????element.attachEvent('onclick'??cb);
????element.onclick=cb;
???????????壺
????type?????????
????listener??????????????????
????useCapture???????????????????true??useCapture???????????????????????????Dom?????·???????????????????????????????????????????????Dom?????е???????????С?????????e??????????????Щ????????????????????????????????DOM Level 3 Events?????useCapture?????false??
????addEventListener??W3C????????DOM Level 2????????????????????????????????????????????????????????????element[’on’+type]???????????????????????????????element[’on’+type]?????????????????????element[’on’+type]????????????????????????????????????????????????????????????????????1???????????0??1.
????element.onclick=function(){console.log(0);}
????element.onclick=function(){console.log(1);}
???????addEventListener??????IE6~8????????в?????????????汾??IE???????????????????????????????????IE??IE5.0??п????????attachEvent()??????????????????????????÷?????????????????????IE 11????????????????????á?
???????????????e??
????W3C?淶?ж?????3???????Σ???????????Ρ?????Ρ?e???Ρ??????????????????·???????????Щ??Ρ?????????β???????????????????????????y?λ??????????????????Event.bubbles??????????false?????e???λ??????????Event.stopPropagation()??????????????????????е??ζ?????????
?????????Σ?????????????????????????????????window?????????????????????????????α?????????????Ρ???????????????????????????????????????????????????
????????Σ???????????????????????α???????????Ρ????????????????????y?ε??????????????????д??????????????????????????????e??????????????????????????????????????
????e???Σ???????????????????????????????????????????????????window???????α?????e???Ρ???????????????????????????e????????д????
????????????????????н?ε????·????????Event.currentTarget???????null????Event.eventPhase?????0??Event???????????????????????????????????Event.target?????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11