首页 > 其他 > 详细

jq on()怎么绑定多个事件

时间:2019-06-30 17:32:42      阅读:110      评论:0      收藏:0      [点我收藏+]

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>评分效果</title>
<script src="../js/jquery.min.js"></script>
<style>
ul li{padding: 0;list-style: none}
li{width: 30px;height: 30px;border: 1px solid #333;float: left;margin-right: 10px}
</style>
</head>
<body>
<ul class="ul01">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<script>
$(function(){
$("li").on({
mouseover:function(){
if($(this).css("backgroundColor") == ‘#ff0000‘){
$(this).css("background","");
console.log($(this).css("backgroundColor"))
}else{
$(this).css("background","red").prevAll("li").css("background","red");
console.log($(this).css("backgroundColor"))
}
},
mouseout: function(){
$(this).css("background","")
},
click: function(){
$(this).off("mouseout")
$(this).css("background","red").prevAll("li").css("background","red");
}
})
})
</script>
</body>
</html>


 

jq on()怎么绑定多个事件

原文:https://www.cnblogs.com/hilxj/p/11110129.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!