denisProsekov
@denisProsekov
' The thought of falling down keeps me alive '

Ошибка Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') Как исправить?

!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/style.css">
</head>

<body>
    <div class="block-1">
        <button class="bt">кнопка</button>
    </div>
    <script src="/script.js"></script>
</body>

</html>


.block-1 {
    margin: 30px 0px 0px 0px;
}


.bt {
    background-color: black;
    color: white;
    border-radius: 5px;
    border: 0;
    font-size: 18px;
    font-weight: 400;
    line-height: 14px;
    padding: 20px 40px 20px 40px;
    margin: 0 auto;
    /*      ↑  →  ↓  ← */
    cursor: pointer;
    justify-content: center;
    display: block;
}


button_console = document.querySelector("bt").addEventListener("click", function name(params) {
    alert(123);
})

61ff6f9fe45a4186523142.png
  • Вопрос задан
  • 82 просмотра
Пригласить эксперта
Ответы на вопрос 1
insighter
@insighter
-First time? - Huh? (C#, React, JS)
... = document.querySelector(".bt") ...
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы