Правильность js кода
<button id = "btn2" onclick = "subs(mark1)">City</button>
<span id = "mark1">London<span id = "mark1s">CITY</span></span>
#mark1{
border-radius:7px;
border:0px solid #60C383;
position:relative;
padding:2px 4px 2px 4px;
}
#mark1s{
width:30px;
height:12px;
background-color:#60C383;
color:black;
font-size:10px;
position:absolute;
left:15px;
top:18px;
border-radius:5px;
display:flex;
justify-content:center;
align-items:center;
display:none;
}
function subs(string){
document.getElementById(`${string}`).style.border = "1px solid #60C383"
document.getElementById(`${string}`"s").style.display = "flex"
}
//вроде проблема в js но в инете мало информации про этой случай, полезного не нашел
//проблема была в первой строке html кода нужно было не onclick = "subs(mark1)" а onclick = "subs('mark1')"
Ответы (1 шт):
Автор решения: Roman
→ Ссылка
function subs(string){
document.getElementById(`${string}`).style.border = "1px solid #60C383"
document.getElementById(`${string}s`).style.display = "flex"
}
#mark1{
border-radius:7px;
border:0px solid #60C383;
position:relative;
padding:2px 4px 2px 4px;
}
#mark1s{
width:30px;
height:12px;
background-color:#60C383;
color:black;
font-size:10px;
position:absolute;
left:15px;
top:18px;
border-radius:5px;
display:flex;
justify-content:center;
align-items:center;
display:none;
}
<button id = "btn2" onclick = "subs('mark1')">City</button>
<span id = "mark1">London<span id = "mark1s">CITY</span></span>