我有以下代码,parentAppliance是主左侧导航表的一部分,并且悬停在“设备”上我看到一个包含“健康”的子表。现在,当我点击健康状态时,我希望子表能够消失吗?
CSS:
.childAppliance
{
display:none;
}
.parentAppliance:hover .childAppliance
{
display: block;
top: 50px;
left: 130px;
}
HTML:
<li id="Appliance" itemid="Appliance" class="parentAppliance" role="presentation">
<a href="#/appliance_status.home" hiddentitle="Appliance" id="ui-id-83" class="ui-corner-all" tabindex="-1" role="menuitem" aria-haspopup="true" title="" data-original-title="">
<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span><ins class="ui-navigation-static-menu-icon ui-navigation-static-menu-icon-backup"></ins>
<span class="ui-navigation-static-menu-text" style="display: inline;">Appliance</span>
</a>
<ul id="ApplianceSubTable" class="ui-menu ui-widget ui-widget-content ui-corner-all childAppliance" role="menu" aria-hidden="true" aria-expanded="false" aria-labelledby="ui-id-83">
<li itemid="Health" class="ui-menu-item" role="presentation">
<a href="#/appliance_status.home" hiddentitle="Health" id="ui-id-33" class="ui-corner-all ui-state-focus applianceFocus" tabindex="-1" role="menuitem" title="">
<span class="ui-navigation-static-menu-text">Health</span>
</a>
</li>
</ul>
</li>
答案 0 :(得分:0)
尝试将onmouseover
事件添加到父设备,并使用其他JavaScript方法重置子显示状态。
<html>
<head>
<style>
.childAppliance
{
display:none;
}
.parentAppliance:hover .childAppliance
{
display: block;
top: 50px;
left: 130px;
}
</style>
<script type="text/javascript">
function toggle(obj) {
var element = document.getElementById(obj);
if(element.style.display == 'none')
element.style.display = 'block';
else
element.style.display = 'none';
}
function show(obj) {
var element = document.getElementById(obj);
element.style.display = '';
}
</script>
</head>
<body>
<li id="Appliance" itemid="Appliance" class="parentAppliance" role="presentation">
<a href="#/appliance_status.home" hiddentitle="Health" id="A1"
class="ui-corner-all ui-state-focus applianceFocus" tabindex="-1" role="menuitem" title=""
onclick="toggle('ApplianceSubTable');" onmouseover="show('ApplianceSubTable');">
<!--<a href="#/appliance_status.home" hiddentitle="Appliance" id="ui-id-83" class="ui-corner-all" tabindex="-1" role="menuitem" aria-haspopup="true" title="" data-original-title="">-->
<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span><ins class="ui-navigation-static-menu-icon ui-navigation-static-menu-icon-backup"></ins>
<span class="ui-navigation-static-menu-text" style="display: inline;">Appliance</span>
</a>
<ul id="ApplianceSubTable" class="ui-menu ui-widget ui-widget-content ui-corner-all childAppliance" role="menu" aria-hidden="true" aria-expanded="false" aria-labelledby="ui-id-83">
<li itemid="Health" class="ui-menu-item" role="presentation">
<a href="#/appliance_status.home" hiddentitle="Health" id="ui-id-33" class="ui-corner-all ui-state-focus applianceFocus" tabindex="-1" role="menuitem" title="">
<span class="ui-navigation-static-menu-text">Health</span>
</a>
</li>
</ul>
</li>
</body>
</html>
答案 1 :(得分:0)