冒泡型事件运行顺序
冒泡型事件运行顺序:
<html onclick="clickHandle('html');"> <head> <title> javascript事件流 </title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta http-equiv="content-type" content="text/html;charset=GBK"/> <script type="text/javascript"> function clickHandle(ele){ alert(ele); } </script> </head> <body onclick=" clickHandle('body'); "> <div style="background-color:red" onclick=" clickHandle('div'); ">click me!</div> </body> </html>
运行点击click me!结果为:div->body->html
由此可知:冒泡型事件是从低而上的触发机制,即从底层元素开始,层层向上,像冒泡一样。