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 οnclick="alert(111)">111</button> </p> <button οnclick="alert(222)">222</button> </body> </html>by 司徒正美
运行代码