document.querySelector("button").onclick = myClick;
function myClick(){
let a = document.querySelector(".input-test");
document.querySelector(".out").innerHTML = a.value;
a.value = "";
}
const list = document.querySelectorAll('.list .test')
window.addEventListener('click', (e)=> {
const target = e.target;
if(target.classList.contains('test')){
resetActiveItem()
target.classList.add('active')
}
if(target.classList.contains('reset')) {
resetActiveItem()
}
})
function resetActiveItem() {
list.forEach(item=>item.classList.remove('active'));
}
const button = document.querySelector('.reset');
button.addEventListener('click', () => {
document.querySelectorAll('.active').forEach(element => element.classList.remove('active'));
});
<div class="reset">сброс цвета</div>
заменить на <button type="button" class="reset">сброс цвета</button>
<div class="wrapper">
<h1 class="title">Заголовок</h1>
</div>
.wrapper {
position: relative;
z-index: 0;
display: flex;
justify-content: center;
}
.wrapper:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 1px;
width: 100%;
background-color: red;
z-index: -1;
margin: auto;
}
.title {
background-color: #fff;
padding: 0 10px;
}
.from-me {
position: relative;
display: none; // добавил свойство
padding: 10px 20px;
color: white;
background: #0b93f6;
border-radius: 25px;
float: right;
}
.loud {
display: block; // добавил свойство
animation-duration: 1.5s;
animation-fill-mode: both;
animation-timing-function: ease-in-out;
transform-origin: center center;
animation-name: loud;
}
.content {
width: 100%; // и тут у тебя ошибка widht
height: 500px
}
const sms = document.querySelector('.from-me');
const scrollHeight = Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
document.addEventListener('scroll',()=>{
window.pageYOffset+document.documentElement.clientHeight===scrollHeight&&sms.classList.add('loud');
})
.text p {
display: inline-block;
position: relative;
}
.text p::before {
content: '';
position: absolute;
left: -30px;
right: -30px;
top: -10px;
height: 6px;
background: radial-gradient(circle, #000 2px, transparent 3px) space center / 10px 6px;
opacity: 0.3;
}