Cannot read properties of null (reading 'addEventListener')
=>
Невозможно обратиться к свойству у null (обращение к 'addEventListener')
burger.addEventListener
null
const burger = document.querySelector('.burger');
querySelector
null
?но картинка меняется только при наведении на другую картинку
img.img11:hover
const blocks = document.querySelectorAll('.div');
blocks.forEach(blk => {
const inputIcon = blk.querySelector('.input-icon');
const inputPass = blk.querySelector('.pass');
inputIcon.addEventListener('click', () => {
if (inputPass.getAttribute('type') == 'password') {
inputIcon.classList.add('view');
inputPass.setAttribute('type', 'text');
} else {
inputIcon.classList.remove('view');
inputPass.setAttribute('type', 'password');
}
})
})
ссылается на переменную item
"Uncaught (in promise) ReferenceError: item is not defined at cartProduct (cart_04.js:13:8)"
Module code is always strict mode code.
for (let item of json) {
+
– это не только оператор сложения, но и оператор конкатенации (соединение строк).const x = +prompt("Введите число") // Унарный плюс преобразует операнд к числовому типу
let l = x + 10
console.log(l)
const x = Number(prompt("Введите число")) // Более явное преобразование
let l = x + 10
console.log(l)
const x = parseInt(prompt ("Введите число")) // Преобразование в целому числу
let l = x + 10
console.log(l)
const x = parseFloat(prompt ("Введите число")) // Преобразование к числу с плавающей точкой
let l = x + 10
console.log(l)
:root {
--color1: white;
}
body.dark {
--color1: black;
}
<body>
<script>
if (localStorage.getItem('theme') === 'dark') document.body.classList.add('dark');
</script>
<li class="nav-item theme-switcher-outer">
<a class="nav-link theme-switcher" href="javascript:switchTheme()">
<i class="fa fa-sun theme-switcher__light"></i>
<i class="fa fa-moon theme-switcher__dark"></i>
</a>
</li>
.theme-switcher {
&__light { display: none; }
&__dark { }
body.dark & {
&__light { display: inline; }
&__dark { display: none; }
}
}
function switchTheme() {
document.body.classList.toggle('dark');
localStorage.setItem('theme', document.body.classList.contains('dark') ? 'dark' : 'light');
}