Выдает ошибки
1)Uncaught TypeError: Cannot set property 'onclick' of null
at index.js:1
2)Uncaught TypeError: Cannot set property 'backgroundColor' of undefined
at HTMLButtonElement.document.getElementById.onclick (index.js:6)
<body>
<p>Login: <input type="text" id="login"></p>
<p>Password: <input type="text" id="password"></p>
<button id="check">Login</button>
<div class="info-block"><span id="info"></span></div>
<script src="js/index.js"></script>
</body>
Код на js
document.getElementById('check').onclick = function(){
let login = document.getElementById('login').value;
let password = document.getElementById('password').value;
let info_block = document.getElementsByClassName('info-block')
if(login == 'admin' && password == '1'){
info_block.style.backgroundColor = 'greenyellow'
info.innerHTML = "Авторизация выполнена успешно!!"
}
else {
// info_block.style.backgroundColor = 'lightcoral';
info.innerHTML = "err!!"
}
}