javascript - jquery hide 隐藏子菜单内容

标签 javascript jquery html css

我正在尝试创建一个包含大量内容的 html 文档,类似于在线手册。我希望只需向下滚动网页即可查看所有内容。我还希望有一个菜单,其中包含网页上部分列表的子菜单,用户可以单击以快速浏览网页。我目前看到一个问题,我的 jquery 代码将所有内容隐藏在我的列表下方,直到我将鼠标悬停在菜单上。 `

<!DOCTYPE html>
 <html>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple jQuery Dropdown Menu | Finished Article</title>

<style type="text/css">

/*style the main menu*/
.myMenu {
    margin:0;
    padding:0;
}

.myMenu li {
    list-style:none;
    float:left;
    font:12px Arial, Helvetica, sans-serif #111;
}

.myMenu li a:link, .myMenu li a:visited {
    display:block;
    text-decoration:none;
    background-color:#09F;
    padding: 0.5em 2em;
    margin:0;
    border-right: 1px solid #fff;
    color:#111;
}

.myMenu li a:hover {
    background-color:#0CF;  
}

/*style the sub menu*/
.myMenu li ul {
    position:absolute;
    visibility:hidden;
    border-top:1px solid #fff;
    margin:0;
    padding:10;
}

.myMenu li ul li {
    display:inline;
    float:none;
}

.myMenu li ul li a:link, .myMenu li ul li a:visited {
    background-color:#09F;
    width:200px;
}

.myMenu li ul li a:hover {
    background-color:#0CF;  
}

</style>

<script type="text/javascript" src="jquery-1.11.0.js"></script>
<script type="text/javascript">
$("#list,#list ul li,#list ul li a").hover(function(){
    $("#text").children().show();
});
$(document).ready(function() {
        $('.myMenu > li').bind('mouseover', openSubMenu);
        $('.myMenu > li').bind('mouseout', closeSubMenu);

        function openSubMenu() {
            $(this).find('ul').css('visibility', 'visible');
        };

        function closeSubMenu() {
            $(this).find('ul').css('visibility', 'hidden');         
        };

});
</script>

</head>
 <body>
 <h1>Pps1:Pps1.Generic.G5</h1>
 <p><a href='#ProcDesc'>ProcedureDescription</a></p>
 <ul class="myMenu">
    <li id="list"><a href="#ProcDesc">Procedure Descriptions</a>
        <ul>
            <li><a href='#Pps1BpTS.TSC'>Pps1BpTS.TSC</a></li>
            <li><a href='#Pps1ContCheck.TSC'>Pps1ContCheck.TSC</a></li>
            <li><a href='#Pps1ErrorText.TSC'>Pps1ErrorText.TSC</a></li>
            <li><a href='#Pps1Exit.TSC'>Pps1Exit.TSC</a></li>
            <li><a href='#Pps1ForceStandby.TSC'>Pps1ForceStandby.TSC</a></li>
            <li><a href='#Pps1Greet.TSC'>Pps1Greet.TSC</a></li>
            <li><a href='#Pps1HWGains.TSC'>Pps1HWGains.TSC</a></li>
            <li><a href='#Pps1Init.TSC'>Pps1Init.TSC</a></li>
            <li><a href='#Pps1LimitActionEStop.TSC'>Pps1LimitActionEStop.TSC</a></li>
        <ul>
    </li>
</ul>
 <h2>Module Description</h2>
 <p>AeroViroment Cycler Generic Module2.3.1, </p>
 <p></p>
 <p>Communication Type: CAN (MS) via CANNeo driver</p>
 <p>Supported Equipment: AV cyclers:AV900, ABC1000, ABC170, ABC150, and MT30</p>
 <p></p>
 <p>It is currently configured to handle Channel A or Channel B on the two channel Cyclers, this is controlled via numPps1Channel which can be set prior to boot up in the Pps1.ini file. This module was made to work as a Cycler Driver in a BcTS/BpTS application. </p>
 <p></p>
 <p>Revision History:</p>
 <p></p>
 <p>2009Jan5, csierra@aanddtech.com, Initial Release for POC testing2.3.2  </p>
 <p>2010Feb5, jdajos@aanddtech.com, fixed init error if test is stopped early and restarted from the beginning.  Pps1Stop.tsc, line 46 added2.3.2  </p>
 <p>2010Feb17, jhaigh@aanddtech.com, added a while loop to all limit action procedures to accommodate local fault log.  If you receive a buld error due to a missing channel flgsyscallout add it to the sys.fil2.3.2</p>
 <p>2010Mar23, daniel.h.vancleve@gm.com, Updated limit action procedures and default/running limits2.3.3</p>
 <p>2010Jun04, abilliau, added chamber safety procedure to all limit action.</p>
 <p>13Sept2010, JHaigh, Added flgPps1SPControl.  When set to 0 and the setpoint goes above or below the cycler high or low imits the iTest runs a sysstop.  When set to 1 and the setpoint goes above or below the high or low limits the setpoint is trimmed to match the limits.  When set to 2 and the setpoint exceeds the limits the setpoint is ignored</p>
 <p>20Sep2010 MBarker, Upped wait for CAN comm timer in Pps1Init to 50 seconds from 30 seconds (which wasnt enough for some cyclers, see Redmine issue #212)</p>
 <p>13March2014, WLowe, Add Pps1BpTS procedure to provide seamless integration into a BpTS Application.</p>

 <h2><a id='ProcDesc'> Procedure Descriptions</a></h2>

 </body>
 </html>
 <h3><a id='Pps1BpTS.TSC'>Pps1BpTS.TSC</h3>
 <blockquote>
 <h4>Procedure Description</h4>
 <p> This procedure is used as a shell to allow the AV module to support BcTS commands
 Pps1BpTS is called from Pps1Init procedure and will run in the background with a loop delay
 of valSysScanPeriod. The AV Modes are defined with the module channel numPps1ModeOut.
 0 = Voltage
 1 = Current
 2 = Power
 3 = Standby
</p>
 <h4>Argument Description</h4>
 <p> None</p>
 <h4>Return Description</h4>
 <p> None

</p>
 </blockquote>
 <h3><a id='Pps1ContCheck.TSC'>Pps1ContCheck.TSC</h3>
 <blockquote>
 <h4>Procedure Description</h4>
 <p> This procedure is used to make sure the AV Cycler has not entered into a fault
 mode. If it enters into a fault condition then flgPps1PackErr is set. I believe 
 flgPps1PackErr has active limits that will cause a fault condition that will shut down the cycler
</p>
 <h4>Argument Description</h4>
 <p> None</p>
 <h4>Return Description</h4>
 <p> None

</p>
 </blockquote>
 <h3><a id='Pps1ErrorText.TSC'>Pps1ErrorText.TSC</h3>
 <blockquote>
 <h4>Procedure Description</h4>
 <p> This procedure is called by Pps1ContCheck and is used to determine what the 
 current problem ID value means and set it to the Packet Error virtual string channel
</p>
 <h4>Argument Description</h4>
 <p> None</p>
 <h4>Return Description</h4>
 <p> None

如果您尝试运行此程序,您会看到菜单出现在顶部,但在您将鼠标悬停在菜单上之前,列表下方的信息不会出现。我究竟做错了什么?

最佳答案

行错别字:

    <li><a href='#Pps1LimitActionEStop.TSC'>Pps1LimitActionEStop.TSC</a></li>
<ul>

应该是</ul> (结束标记)

关于javascript - jquery hide 隐藏子菜单内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22518136/

相关文章:

javascript - 从 for 循环中推送一个数组并将对象存储到 Mongoose 中,是重复值

javascript - 如何在@click 上更新模板

javascript - typescript XXX.isSupported 不是函数

javascript - 正则表达式在 jquery 中只允许数字和单点

html - 使用 CSS 将图像定位在以下 <div> 之上

javascript - 使用 Node.js 连接到 REST API

javascript - Ajax 分配的变量在分配后无法访问

javascript - 我无法在浏览器中获取我绘制的图片

javascript - 汉堡下拉菜单打不开

php - 从表 A 中选择选项后显示表 B 中的数据