我想要的结果是这样的:
<div id="lay3498_3_1" onClick="" style="position:absolute; width:720px; height:20px; z- index:3498;left:277px; top: 169px; background-color: #FFCCCC; layer-background-
color: #FFCCCC; border: 1px none #000000;">
<table width="100%" height="20" border="1" bgcolor="#FFBFAA" cellpadding="0"
cellspacing="0">
<tr>
<td>
<a href="" title="标题1" onClick="openurl(id);return false;"> </a>
</td>
</tr>
</table>
</div>
<div id="lay3498_3_2" onClick="" style="position:absolute; width:720px; height:20px; z- index:3498;left:277px; top: 242px; background-color: #FFCCCC; layer-background-
color: #FFCCCC; border: 1px none #000000;">
<table width="100%" height="20" border="1" bgcolor="#FFBFAA" cellpadding="0"
cellspacing="0">
<tr>
<td>
<a href="" title="标题2" onClick="openurl(id);return false;"> </a>
</td>
</tr>
</table>
</div>
<div id="lay3498_3_3" onClick="" style="position:absolute; width:720px; height:20px; z- index:3498;left:277px; top: 355px; background-color: #FFCCCC; layer-background-
color: #FFCCCC; border: 1px none #000000;">
<table width="100%" height="20" border="1" bgcolor="#FFBFAA" cellpadding="0"
cellspacing="0">
<tr>
<td>
<a href="" title="标题3" onClick="openurl(id);return false;"> </a>
</td>
</tr>
</table>
</div>
<div id="lay3499_1_1" onClick="" style="position:absolute; width:720px; height:20px; z- index:3499;left:290px; top: 355px; background-color: #FFCCCC; layer-background-
color: #FFCCCC; border: 1px none #000000;">
<table width="100%" height="20" border="1" bgcolor="#FFBFAA" cellpadding="0"
cellspacing="0">
<tr>
<td>
<a href="" title="标题3" onClick="openurl(id);return false;"> </a>
</td>
</tr>
</table>
</div>
以上是三个图层,现在我想用JavaScript来控制这四个图层,DIV的ID分别是:lay3498_3_1,lay3498_3_2,lay3498_3_3,lay3499_1_1,他们的z-index的值分别是:3498,3498,3498,3499,第四个图层在第三个图层的后面(第四个图层的left值为:290,第三个图层的left值为:277),现要获取DIV的ID属性值,lay3498_3_1代表的意思是:第一个下划线前是定值(通过获取数据),第一个下划线后的值是代表有几个z-index值是一样的,这里是3个,最后一个数字代表当前相同z-index的时候是第几个.现要的结果是当我选中z-index值是一样的层是,其它的层也要同时出现在最上面,这样如何来写JavaScript来实现,谢谢各位!谢谢!
<style>
div{t:expression(this.onclick=function(){show(this)})}
</style>
<script>
function show(obj)
{
if(/lay3498/.test(obj.id))
{
for(var i=1;i<=3;i++)
{
document.getElementById(lay3498_3_+i.toString()).style.zIndex=document.getElementById(lay3499_1_1).style.zIndex+1;
}
}
else
{
for(var i=1;i<=3;i++)
{
document.getElementById(lay3498_3_+i.toString()).style.zIndex=document.getElementById(lay3499_1_1).style.zIndex-1;
}
}
}
</script>
<body>
<div id="lay3498_3_1" onClick="" style="position:absolute; width:720px; height:20px; z-index:3498;left:277px; top: 169px; background-color: #FFCCCC; layer-background-
color: #FFCCCC; border: 1px none #000000;">
<table width="100%" height="20" border="1" bgcolor="#FFBFAA" cellpadding="0"
cellspacing="0">
<tr>
<td>
<a href="" title="标题1" onClick="openurl(id);return false;"> </a>
</td>
</tr>
</table>
</div>
<div id="lay3498_3_2" onClick="" style="position:absolute; width:720px; height:20px; z-index:3498;left:277px; top: 242px; background-color: #FFCCCC; layer-background-
color: #FFCCCC; border: 1px none #000000;">
<table width="100%" height="20" border="1" bgcolor="#FFBFAA" cellpadding="0"
cellspacing="0">
<tr>
<td>
<a href="" title="标题2" onClick="openurl(id);return false;"> </a>
</td>
</tr>
</table>
</div>
<div id="lay3498_3_3" onClick="" style="position:absolute; width:720px; height:20px; z-index:3498;left:277px; top: 355px; background-color: #FFCCCC; layer-background-
color: #FFCCCC; border: 1px none #000000;">
<table width="100%" height="20" border="1" bgcolor="#FFBFAA" cellpadding="0"
cellspacing="0">
<tr>
<td>
<a href="" title="标题3" onClick="openurl(id);return false;"> </a>
</td>
</tr>
</table>
</div>
<div id="lay3499_1_1" onClick="" style="position:absolute; width:720px; height:20px; z-index:3499;left:290px; top: 355px; background-color: #FFCCCC; layer-background-
color: #FFCCCC; border: 1px none #000000;">
<table width="100%" height="20" border="1" bgcolor="#FFBFAA" cellpadding="0"
cellspacing="0">
<tr>
<td>
<a href="" title="标题3" onClick="openurl(id);return false;"> </a>
</td>
</tr>
</table>
</div>
</body>