点击表格行(学生姓名)时显示对应的层(学生信息),当点击其他行时原层的隐藏问题
效果:点击表格行(学生姓名)时显示对应的层(学生信息),当点击其他行时原层隐藏,显示其对应的层。
问题:表格
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->function ShowChosen(divID){
divID.style.display='block';
div=divID;
}
function selectRow(rowID)
{
var tStu = document.getElementById("tblStudent")
for(var i=0;i<tStu.rows.length;i++) //遍历所有行
{
if (tStu.rows[i] != rowID) //判断是否当前选定行
{
tStu.rows[i].bgColor = "#F1ECCD"; //设置背景色
tStu.rows[i].onmouseover = resumeRowOver; //增加onmouseover 事件
tStu.rows[i].onmouseout = resumeRowOut;//增加onmouseout 事件
}
else
{
tStu.rows[i].bgColor = "#DCD8BF";
tStu.rows[i].onmouseover = ""; //去除鼠标事件
tStu.rows[i].onmouseout = ""; //去除鼠标事件
}
}
}
//移过时tr的背景色
function rowOver(row)
{
row.bgColor='#DCD8BF';
}
//移出时tr的背景色
function rowOut(row)
{
row.bgColor='#F1ECCD';
}
//恢复tr的的onmouseover事件配套调用函数
function resumeRowOver()
{
rowOver(this);
}
//恢复tr的的onmouseout事件配套调用函数
function resumeRowOut()
{
rowOut(this);
}
function HideChosen(divID){
divID.style.display='none';
}
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><table border="0" width="100%" id="tblStudent">
<?php
$sql="SELECT * FROM student ORDER BY AddTime desc";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query))
{
?>
<tr id="r<?php echo $row['stuName']?>"; onclick="ShowChosen(<?php echo $row['stuName']?>); selectRow(r<?php echo $row
['stuName']?>)" onmouseover="rowOver(r<?php echo $row['stuName']?>)" onmouseout="rowOut(r<?php echo $row['stuName']?>)">
<td width="1%"></td>
<td width="84%">
<?php echo $row['stuName']?>
</td>
<td width="84"></td>
</tr>
<?php
}
?>
</table>
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><?php
$sql="SELECT * FROM student ORDER BY AddTime desc";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query))
{
?>
<div style="position: relative; width: 233px; height: 135px; z-index: 2; left:5px; top:0px" id="<?php echo $row['stuName']?>"
style="display:none">
<table border="0" width="100%">
<tr>
<td><?php echo $row['stuInfo']?></td>
</tr>
</table>
</div>
<?php
}
?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
C++高性能并发应用_C++如何开发性能关键应用
Java AI集成Deep Java Library_Java怎么集成AI模型部署
Golang后端API开发_Golang如何高效开发后端和API
Python异步并发改进_Python异步编程有哪些新改进
C++系统编程内存管理_C++系统编程怎么与Rust竞争内存安全
Java GraalVM原生镜像构建_Java怎么用GraalVM构建高效原生镜像
Python FastAPI异步API开发_Python怎么用FastAPI构建异步API
C++现代C++20/23/26特性_现代C++有哪些新标准特性如modules和coroutines
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号