IE回车的一个怪异行为

IE中在input中回车相当于提交form,会从dom中找最近的button标签触发click事件

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <h1>by 司徒正美</h1>
        <p><input class="text" placeholder='在input框里面按回车键,触发了button的click事件'/></p>
        <p>
            <button onclick="alert(111)">111</button>
        </p>
        <button onclick="alert(222)">222</button>
    </body>
</html>

原文地址:https://www.cnblogs.com/rubylouvre/p/3401200.html