关于jq显示隐藏的效果

WBOY
Release: 2016-06-23 13:53:18
Original
912 people have browsed it


按钮
内容



$('#mune_1').hover(function(){
$('.second_mune').show();
},function(){
$('.second_mune').hide();
})


我修改成这样,因为鼠标经过的a标签和要显示内容的span不在同一个div上,所以我鼠标指向a标签显示内容后,再移到span标签上还是会隐藏掉,怎样修改才能让鼠标移到a标签和span标签都能显示内容??


回复讨论(解决方案)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <meta http-equiv="content-type" content="text/html;charset=utf-8">  <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>  <title> js test </title> </head> <body>	<a class="mune_1">按钮</a>	<span class="second_mune" style="display:none">内容</span>  <script type="text/javascript">    var et = null;	$('.mune_1').hover(function(){		if(et!=null){			clearTimeout(et);		}		$('.second_mune').show();	},function(){		et = setTimeout(function(){			$('.second_mune').hide();			},100);		})	$('.second_mune').hover(function(){		if(et!=null){			clearTimeout(et);		}		$('.second_mune').show();	},function(){		et = setTimeout(function(){			$('.second_mune').hide();			},100);		})	  </script> </body></html>
Copy after login

感觉加个容器比较好

<span>    <a class="mune_1">按钮</a>    <span class="second_mune" style="display:none">内容</span></span>
Copy after login
    $('.mune_1').hover(function(){      $(this).parent().hover(function(){        $('.second_mune').show();      },function(){        $('.second_mune').hide();      })    })   
Copy after login

三楼的 加个parent(),鼠标移到其它a标签上也会显示层了,怎么解决??

不错学习一下

2楼的是可以 

不知道!
我只能满足你已提出的要求
无法预测你还会做什么

好的 还是要谢谢

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template