jquery bind click mouseout hover mouseover事件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>


<style type="text/css"> 
.highlight{
background:#FF3300;
}
</style> 


<script src="../js/jquery-1.8.3.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){


$("#panel h5.head").bind("click",function(){
if($(this).next("div.content").is(":visible")){
$(this).next("div.content").hide();
}else{
//$(this).next("div.content").show();
//$(this).next("div.content").fade(2000);
$(this).next("div.content").slideDown(100);
}
})

$("#panel1 h5.head1").bind("mouseout",function(){
$(this).next("div.content1").hide();
})
$("#panel1 h5.head1").bind("mouseover",function(){
$(this).next("div.content1").show();
})




$("#panel2 h5.head2").hover(function(){
$(this).next("div.content2").show();
},function(){
$(this).next("div.content2").hide();
})







$("#panel3 h5.head3").mouseover(function(){
$(this).next("div.content3").show();
})

$("#panel3 h5.head3").mouseout(function(){
$(this).next("div.content3").hide();
})


$("#panel4 h5.head4").toggle(function(){
$(this).addClass("highlight")
$(this).next("div.content4").show();
},function(){
$(this).removeClass("highlight");
$(this).next("div.content4").hide();
})
$("#panel5 h5.head5").bind("mouseout mouseover",function(){
if($(this).next("div.content5").is(":visible")){
$(this).next("div.content5").hide();
}else{
$(this).next("div.content5").show();
}
})



 
})

</script>






<body>
<div id="panel">


<h5 class="head">点击一下吧</h5>
<div class="content" style="display:none">
点击之后我出来了
</div>
</div>
<div id="panel1">


<h5 class="head1">鼠标移到这现实</h5>
<div class="content1" style="display:none">
我显示了
</div>
</div>
<div id="panel2">


<h5 class="head2">使用了hover(自定义方法)</h5>
<div class="content2" style="display:none">
我显示了
</div>
</div>


<div id="panel3">


<h5 class="head3">使用了mouseout,mouseover</h5>
<div class="content3" style="display:none">
我显示了
</div>
</div>


<div id="panel4">


<h5 class="head4">使用toggle</h5>
<div class="content4" style="display:none">
我显示了
</div>
</div>
<div id="panel5">


<h5 class="head5">bind绑定多个事件</h5>
<div class="content5"style="display:none" >
我显示了
</div>
</div>
</body>

</html>

欢迎大家加入java资源免费分享群,群号:814657026

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值