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>

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2022-01-02
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
猜你喜欢
  • 2021-10-07
  • 2021-10-20
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案