Answer the question
In order to leave comments, you need to log in
How to output one class by default, and then what would the if construct work?
Good afternoon, there is a construction like:
<td style="padding: 0px 0px;" <?if($result['PROPERTY_115_ENUM_ID'][$key]) {echo 'class="type'.$result['PROPERTY_115_ENUM_ID'][$key].'"';} ?>>
<a onclick="type1()" id="xx_type_1" class="selected"><span>Первое</span></a>
<a onclick="type2()" id="xx_type_2" class=""><span>Второе</span></a>
<a onclick="type3()" id="xx_type_3" class=""><span>Третье</span></a>
function type2() {
var elements1t = document.getElementsByClassName('type2');
for (var i = 0; i < elements1t.length; i++) {
elements1t[i].style.display="";
}
var elements2t = document.getElementsByClassName('type1');
for (var i = 0; i < elements2t.length; i++) {
elements2t[i].style.display="none";
}
var elements3t = document.getElementsByClassName('type3');
for (var i = 0; i < elements3t.length; i++) {
elements3t[i].style.display="none";
}
document.getElementById('xx_type_1).classList.remove('selected');
document.getElementById('xx_type_2').classList.add('selected');
document.getElementById('xx_type_3').classList.remove('selected');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question