<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery遍历数组/添加鼠标滑动事件-添加/移除属性</title>
<style type="text/css">
*{
padding:0;
margin:0;
}
div{
margin:50px auto;
width: 300px;
height: 270px;
background: #f6f9fa;
}
</style>
</head>
<body>
<div></div>
<script src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$('div').each(function(index,item){
// 鼠标移入时,div背景变成白色、加阴影
$(this).mouseover(function(){
$(this).css({"background-color":"#FFF",
"box-shadow":"0px -1px 10px 3px rgba(24,199,255,0.05),"+ //上边
"-1px 0px 10px 3px rgba(24,199,255,0.05),"+ //左边
"0px 1px 10px 3px rgba(24,199,255,0.05),"+ //下边
"1px 0px 10px 3px rgba(24,199,255,0.05)"}); //右边
});
//鼠标移出时,复原
$(this).mouseout(function(){
$(this).css({"background-color":"#f6f9fa","box-shadow":"none"});
});
});
</script>
</body>
</html>