我有这个js函数来显示/隐藏div id =“xdata”
function xdataview(){
var estado = document.getElementById('xdata').style.visibility;
if (estado==="hidden"){
document.getElementById('xdata').style.visibility = "visible";
} else {
document.getElementById('xdata').style.visibility = "hidden";
}
}
这里面有一个do循环的PHP循环
<div id="xdata" class="extradata">
<?php
$saidas = $row_RSplano['TotalSaidas'];
$entradas = $row_RSplano['TotalEntradas'];
$saldo = $saidas - $entradas;
echo "S:" . $saidas . " / " . "E:" . $entradas . " >>>> SALDO:" . $saldo;
?>
</div>
问题是这只适用于我的sql结果中的第一个div。我不能隐藏/显示第二行div
答案 0 :(得分:0)
一种方法
divs=document.getElementsByTagName("DIV");
for (theDiv in divs) {
if (divs[theDiv].className=="extradata") divs[theDiv].style.visibility="hidden";
}
感谢大家