<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
简单代码 高亮当前行
<script>
var theObj;
function hilight(obj){
if(theObj!=null){theObj.style.background = "#fff";}
if(theObj = obj){obj.style.background = "red";}
}
</script>
<ul>
<li onclick="hilight(this)">点击高亮当前行</li>
<li onclick="hilight(this)">点击高亮当前行1</li>
<li onclick="hilight(this)">点击高亮当前行2</li>
<li onclick="hilight(this)">点击高亮当前行3</li>
<li onclick="hilight(this)">点击高亮当前行4</li>
</ul>
<p>下面另起一段列表</p>
<ul>
<li onclick="hilight(this)">点击高亮当前行</li>
<li onclick="hilight(this)">点击高亮当前行1</li>
<li onclick="hilight(this)">点击高亮当前行2</li>
<li onclick="hilight(this)">点击高亮当前行3</li>
<li onclick="hilight(this)">点击高亮当前行4</li>
</ul>
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)