单击 时,我需要.card
出现一个块.copied
,但由于某种原因,没有任何效果。
let elem = document.getElementsByClassName('card');
let warn = document.getElementsByClassName('copied');
for (let i = 0; i < elem.length; i++) elem[i].onclick = function() {
warn.style.display = 'block';
setTimeout(function() {
warn.style.display = 'none';
}, 3000);
}
.copied {
display: none;
position: absolute;
bottom: 40px;
right: 40px;
padding: 10px 30px;
border-radius: 8px;
background-color: #8dffc0;
font-size: 14px;
}
.cards {
display: flex;
width: 100%;
align-items: flex-start;
flex-wrap: wrap;
justify-content: space-around;
}
.card {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 250px;
height: 150px;
border: 1px solid #c4c4c4;
margin-top: 5px;
font-size: 28px;
cursor: pointer;
}
<div class="copied">Скопировано</div>
<div class="cards">
<div class="card" data-clipboard-text="¯\_(ツ)_/¯">
¯\_(ツ)_/¯
</div>
<div class="card" data-clipboard-text="☚(゚ヮ゚☚)">
☚(゚ヮ゚☚)
</div>
<div class="card" data-clipboard-text="٩(●ᴗ●)۶">
٩(●ᴗ●)۶
</div>
</div>
1 个回答