Программисты Html
Anonymous
Как я могу сделать это, чтобы я не мог не привести к выбору своего выбора?
Сообщение
Anonymous » 11 июл 2025, 17:35
Как я могу сделать так, чтобы я не смог не выбирать свой выбор? Если я снова нажимаю на один и тот же текст, я не хочу, чтобы всплывающее окно исчезало. Мне действительно нужно это для моего проекта, может ли кто-нибудь помочь мне с этим?
Код: Выделить всё
let clickedId = null
function clickTest(id) {
if(clickedId){
if(id!=clickedId){
return null
}else{
clickedId = null
}
}else{
clickedId = id
}
var senior = document.getElementById(id);
senior.classList.toggle("show");
}< /code>
.junior {
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.adult {
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.senior {
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.junior .juniortext {
visibility: hidden;
width: 160px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
}
.adult .adulttext {
visibility: hidden;
width: 160px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
}
.senior .seniortext {
visibility: hidden;
width: 160px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
}
.junior .juniortext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.adult .adulttext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.senior .seniortext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.junior .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 1s;
}
.adult .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 1s;
}
.senior .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 1s;
}
@-webkit-keyframes fadeIn {
from {opacity: 0;}
to {opacity: 1;}
}
@keyframes fadeIn {
from {opacity: 0;}
to {opacity:1 ;}
}< /code>
JUNIOR
A Simple junior Popup!
ADULT
A Simple adult Popup!
SENIOR
A Simple senior Popup!
Подробнее здесь:
https://stackoverflow.com/questions/742 ... -my-choice
1752244550
Anonymous
Как я могу сделать так, чтобы я не смог не выбирать свой выбор? Если я снова нажимаю на один и тот же текст, я не хочу, чтобы всплывающее окно исчезало. Мне действительно нужно это для моего проекта, может ли кто-нибудь помочь мне с этим?[code]let clickedId = null function clickTest(id) { if(clickedId){ if(id!=clickedId){ return null }else{ clickedId = null } }else{ clickedId = id } var senior = document.getElementById(id); senior.classList.toggle("show"); }< /code> .junior { position: relative; display: inline-block; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .adult { position: relative; display: inline-block; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .senior { position: relative; display: inline-block; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .junior .juniortext { visibility: hidden; width: 160px; background-color: #555; color: #fff; text-align: center; border-radius: 6px; padding: 8px 0; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -80px; } .adult .adulttext { visibility: hidden; width: 160px; background-color: #555; color: #fff; text-align: center; border-radius: 6px; padding: 8px 0; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -80px; } .senior .seniortext { visibility: hidden; width: 160px; background-color: #555; color: #fff; text-align: center; border-radius: 6px; padding: 8px 0; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -80px; } .junior .juniortext::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #555 transparent transparent transparent; } .adult .adulttext::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #555 transparent transparent transparent; } .senior .seniortext::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #555 transparent transparent transparent; } .junior .show { visibility: visible; -webkit-animation: fadeIn 1s; animation: fadeIn 1s; } .adult .show { visibility: visible; -webkit-animation: fadeIn 1s; animation: fadeIn 1s; } .senior .show { visibility: visible; -webkit-animation: fadeIn 1s; animation: fadeIn 1s; } @-webkit-keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} } @keyframes fadeIn { from {opacity: 0;} to {opacity:1 ;} }< /code> JUNIOR A Simple junior Popup! ADULT A Simple adult Popup! SENIOR A Simple senior Popup! [/code] Подробнее здесь: [url]https://stackoverflow.com/questions/74217675/how-can-i-make-it-so-that-i-cant-unselect-my-choice[/url]