层的隐藏 逻辑有问题:>鼠标移开,子目录消失>当鼠标移往别处的的时候,最后一个显示的子类不会消失 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是一个纯js的问题。关键在于当显示某个层时关闭其他的层,鼠标离开本层时关闭自己。建议你离开服务器,单独调试js部分。 我添加了hiddenIt()隐藏所有的层,可是问题又来了:倒是可以隐藏层,但是鼠标离开第一层目录而去点击其子目录的时候,子目录也随之不见了!!//function hiddenIt()echo " function hiddenIt() \n ";echo " { \n";echo " for(j = 0;j<count1;j++) \n ";echo " { \n ";echo " whichE1 = eval('a' + j ); \n";echo " whichE1.style.visibility = 'hidden'; \n ";echo " } \n ";echo " } \n ";<table width="90%" border="0" ><tr><?php for ($i=0;$i<$count1;$i++){ ?><td> <table> <tr> <td onMouseOver="showIt('<?php echo $i;?>')"> <a href='select_result.php?typename=<?php echo $type1[$i]; ?>'><?php echo $type1[$i];?></a> </td> </tr> <tr> <td> <div id="<?php echo 'a'.$i;?>" style="position:absolute; width:113px; height:82px; z-index:1; left: 3px; top: 33px; visibility: hidden;"> <table> <?php for ($j=0;$j<$count2[$i];$j++){ ?> <tr> <td onMouseOut="hiddenIt()" bgcolor="#99cccc"> <a href='select_result.php?typename=<?php echo $type2[$i][$j]; ?>'><?php echo $type2[$i][$j];?></a> </td> </tr> <?php } ?> </table> </div> </td> </tr> </table></td><?php } ?></tr></table> hiddenIt():隐藏所有的层showIt():隐藏其他的层,显示当前鼠标所指目录的子目录<td onMouseOver="showIt('<?php echo $i;?>')"> 当鼠标移到一个一级目录的时候,显示其子目录<td onMouseOut="hiddenIt()" bgcolor="#99cccc"><a href='select_result.php?typename=<?php echo $type2[$i][$j]; ?>'><?php echo $type2[$i][$j];?></a></td>鼠标离开子目录,就隐藏所有的层请问楼上的大虾,你觉得思路应该是怎样的呢? 这是源码:<script LANGUAGE=JavaScript>count1 = 2; var type1=new Array();type1[0] ='a0';type1[1] ='a1';var lastObj=null; function showIt(i) { var o=window.event.srcElement; var oPosT=o.offsetTop; var oPosL=o.offsetLeft; while(o=o.offsetParent){ //if(o==NaN) continue; oPosT+=o.offsetTop; oPosL+=o.offsetLeft;}if(lastObj!=null) lastObj.style.visibility='hidden'; whichE1 = eval('a' + i ); whichE1.style.pixelLeft=oPosL; whichE1.style.pixelTop=oPosT+25; whichE1.style.visibility = 'visible'; lastObj=whichE1; } function hiddenIt() { for(j = 0;j<count1;j++) { whichE1 = eval('a' + j ); whichE1.style.visibility = 'hidden'; } } </script> <body><table width="90%" border="0" ><tr><td> <table> <tr> <td onMouseOver="showIt('0')"> <a href='select_result.php?typename=动作'>动作</a> </td> </tr> <tr> <td> <div id="a0" style="position:absolute; width:113px; height:82px; z-index:1; left: 3px; top: 33px; visibility: hidden;"> <table> <tr> <td onMouseOut="hiddenIt()" bgcolor="#99cccc"> <a href='select_result.php?typename=a'>a</a> </td> </tr> <tr> <td onMouseOut="hiddenIt()" bgcolor="#99cccc"> <a href='select_result.php?typename=gg'>gg</a> </td> </tr> </table> </div> </td> </tr> </table></td><td> <table> <tr> <td onMouseOver="showIt('1')"> <a href='select_result.php?typename=爱情'>爱情</a> </td> </tr> <tr> <td> <div id="a1" style="position:absolute; width:113px; height:82px; z-index:1; left: 3px; top: 33px; visibility: hidden;"> <table> <tr> <td onMouseOut="hiddenIt()" bgcolor="#99cccc"> <a href='select_result.php?typename=hh'>hh</a> </td> </tr> <tr> <td onMouseOut="hiddenIt()" bgcolor="#99cccc"> <a href='select_result.php?typename=gggg'>gggg</a> </td> </tr> </table> </div> </td> </tr> </table></td></tr></table></body> 留言板被发布乱七八糟的代码 MySQL Errno : 1064 PHPCMS2008问题 请高手指点-一个web 控件可不可以用多个 css class 请问,全文搜索怎样应用于多表? wordpres引用56网视频,用手机端浏览的情况 在线等,如何动态选择数据库表中的列???? 怎么屏蔽浏览器工具栏的后退和右键后退??? global 问题(答后即结) php CI 中的日期 织梦城市分站插件,后台要修改哪里的代码啊 ? php中gd模块已加载,为何不能调用imagefig()函数!内祥! 关于如何控制换页?
关键在于当显示某个层时关闭其他的层,鼠标离开本层时关闭自己。建议你离开服务器,单独调试js部分。
echo " function hiddenIt() \n ";
echo " { \n";
echo " for(j = 0;j<count1;j++) \n ";
echo " { \n ";
echo " whichE1 = eval('a' + j ); \n";
echo " whichE1.style.visibility = 'hidden'; \n ";
echo " } \n ";
echo " } \n ";
<table width="90%" border="0" >
<tr>
<?php for ($i=0;$i<$count1;$i++){ ?>
<td>
<table>
<tr>
<td onMouseOver="showIt('<?php echo $i;?>')">
<a href='select_result.php?typename=<?php echo $type1[$i]; ?>'><?php echo $type1[$i];?></a>
</td>
</tr>
<tr>
<td>
<div id="<?php echo 'a'.$i;?>" style="position:absolute; width:113px; height:82px; z-index:1; left: 3px; top: 33px; visibility: hidden;">
<table>
<?php for ($j=0;$j<$count2[$i];$j++){ ?>
<tr>
<td onMouseOut="hiddenIt()" bgcolor="#99cccc">
<a href='select_result.php?typename=<?php echo $type2[$i][$j]; ?>'><?php echo $type2[$i][$j];?></a>
</td>
</tr>
<?php } ?>
</table>
</div>
</td>
</tr>
</table>
</td>
<?php } ?>
</tr>
</table>
showIt():隐藏其他的层,显示当前鼠标所指目录的子目录<td onMouseOver="showIt('<?php echo $i;?>')"> 当鼠标移到一个一级目录的时候,显示其子目录<td onMouseOut="hiddenIt()" bgcolor="#99cccc">
<a href='select_result.php?typename=<?php echo $type2[$i][$j]; ?>'><?php echo $type2[$i][$j];?></a>
</td>
鼠标离开子目录,就隐藏所有的层请问楼上的大虾,你觉得思路应该是怎样的呢?
count1 = 2;
var type1=new Array();
type1[0] ='a0';
type1[1] ='a1';
var lastObj=null;
function showIt(i)
{
var o=window.event.srcElement;
var oPosT=o.offsetTop;
var oPosL=o.offsetLeft;
while(o=o.offsetParent){
//if(o==NaN) continue;
oPosT+=o.offsetTop;
oPosL+=o.offsetLeft;
}
if(lastObj!=null) lastObj.style.visibility='hidden'; whichE1 = eval('a' + i );
whichE1.style.pixelLeft=oPosL;
whichE1.style.pixelTop=oPosT+25; whichE1.style.visibility = 'visible';
lastObj=whichE1; }
function hiddenIt()
{
for(j = 0;j<count1;j++)
{
whichE1 = eval('a' + j );
whichE1.style.visibility = 'hidden';
}
}
</script>
<body><table width="90%" border="0" >
<tr>
<td>
<table>
<tr>
<td onMouseOver="showIt('0')">
<a href='select_result.php?typename=动作'>动作</a>
</td>
</tr>
<tr>
<td>
<div id="a0" style="position:absolute; width:113px; height:82px; z-index:1; left: 3px; top: 33px; visibility: hidden;">
<table>
<tr>
<td onMouseOut="hiddenIt()" bgcolor="#99cccc">
<a href='select_result.php?typename=a'>a</a>
</td>
</tr>
<tr>
<td onMouseOut="hiddenIt()" bgcolor="#99cccc">
<a href='select_result.php?typename=gg'>gg</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td onMouseOver="showIt('1')">
<a href='select_result.php?typename=爱情'>爱情</a>
</td>
</tr>
<tr>
<td>
<div id="a1" style="position:absolute; width:113px; height:82px; z-index:1; left: 3px; top: 33px; visibility: hidden;">
<table>
<tr>
<td onMouseOut="hiddenIt()" bgcolor="#99cccc">
<a href='select_result.php?typename=hh'>hh</a>
</td>
</tr>
<tr>
<td onMouseOut="hiddenIt()" bgcolor="#99cccc">
<a href='select_result.php?typename=gggg'>gggg</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table></body>