代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <button onclick=alert("谁让你点的")>别点</button> <button id="id1">点开吧</button> <script> document.getElementById(‘id1‘).onclick=function () { alert("让你点你就点啊"); } </script> </body> </html>
即可