Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete does not take effect when remove the event handler #231

Open
Levix0501 opened this issue Jan 12, 2022 · 0 comments
Open

delete does not take effect when remove the event handler #231

Levix0501 opened this issue Jan 12, 2022 · 0 comments

Comments

@Levix0501
Copy link

Levix0501 commented Jan 12, 2022

in "Attach or detach an event handler”

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Static Template</title>
    <style></style>
  </head>
  <body>
    <button id="btn1">onclick</button>
  </body>
  <script>
    function fn1() {
      alert(1);
    }
    const btn1 = document.getElementById("btn1");
    btn1.onclick = fn1;
    console.log(btn1);

    let res = delete btn1.onclick;
    console.log(res);

    console.log(btn1.onclick);
  </script>
</html>
@Levix0501 Levix0501 changed the title Why can't I use "delete" to remove the event handler can't use "delete" to remove the event handler Jan 12, 2022
@Levix0501 Levix0501 changed the title can't use "delete" to remove the event handler delete does not take effect when remove the event handler Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant