<!DOCTYPE html>
<html>
<head lang="ru">
<title>js</title>
<link rel="stylesheet" href="style.css">
<script>
window.onload = function () {
let clck = false;
for (let i = 0; i < document.images.length; ++i) {
document.images[i].addEventListener('mousedown', function (e) {
if (clck == false) {
document.images[i].style.transition = 1 + 's';
document.images[i].style.width = 400 + 'px';
clck = true;
}
})
document.images[i].addEventListener('mousedown', function (e) {
if (clck == true) {
document.images[i].style.transition = 1 + 's';
document.images[i].style.width = 400 + 'px';
clck = false;
}
})
}
}
</script>
<style>
img {
width: 100px;
}
</style>
</head>
<body id="body">
<img src="C:/Users/sds63/Pictures/for loop.png" alt="">
<img src="C:/Users/sds63/Pictures/addEventListener.jpg" alt="">
<img src="C:/Users/sds63/Pictures/MakeToDoListFromThisIMG.png" alt="">
</body>
</html>
сверху нерабочий
снизу рабочий
<!DOCTYPE html>
<html>
<head lang="ru">
<title>js</title>
<link rel="stylesheet" href="style.css">
<script>
window.onload = function () {
let clck = false;
for (let i = 0; i < document.images.length; ++i) {
document.images[i].addEventListener('mousedown', function (e) {
if (clck == false) {
document.images[i].style.transition = 1 + 's';
document.images[i].style.width = 400 + 'px';
clck = true;
}
else {
document.images[i].style.transition = 1 + 's';
document.images[i].style.width = 100 + 'px';
clck = false;
}
})
}
}
</script>
<style>
img {
width: 100px;
}
</style>
</head>
<body id="body">
<img src="C:/Users/sds63/Pictures/for loop.png" alt="">
<img src="C:/Users/sds63/Pictures/addEventListener.jpg" alt="">
<img src="C:/Users/sds63/Pictures/MakeToDoListFromThisIMG.png" alt="">
</body>
</html>