Не изменять структуру и ответить на комментарий TS
Можете ли вы помочь мне с javascript, как это будет работать
Javascript версия
document.getElementById("check").onchange = function() {
const element = document.getElementById("hello_id");
element.classList.toggle("blue");
}
.blue {
color: blue;
}
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div>
<input type="checkbox" id="check" class="checkclick" />
<span>Hello One next</span>
</div>
<div class="one">
<div class="two">
<div class="hello" id="hello_id">hello world</div>
</div>
</div>
</body>
</html>
JQuery версия
$("#check").change(function() {
$("#hello_id").toggleClass("blue");
});
.blue {
color: blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div>
<input type="checkbox" id="check" class="checkclick" />
<span>Hello One next</span>
</div>
<div class="one">
<div class="two">
<div class="hello" id="hello_id">hello world</div>
</div>
</div>
</body>
</html>