您的位置:首页 > Web前端 > JQuery

jQuery选择器 标签选择元素+css简单添加移除操作

2017-07-26 20:52 816 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery选择器</title>
<!--jQuery选择器类似于CSS选择器 具体规则见:http://jquery.cuishifeng.cn/-->
<style>
img{

border: 1px solid gray;
width: 200px;
height: 200px;
margin: 10px;
}
.a{
border: 3px dotted green;
}
</style>
<script src="../../../js/jquery-3.1.1.min.js"></script>
<script>
$(function(){
//选择元素,添加事件    直接在$后面的('')中输入要操作的元素
$('img').mouseover(function(){//当鼠标悬浮时 为img添加a类
//$(this).css('border','5px solid red');
$(this).addClass('a');
}).mouseout(function(){//当鼠标移开时删除a类
//$(this).css('border','10px solid orange');
$(this).removeClass('a')
})
})
</script>
</head>
<body>
<img src="../../../img/01.jpg" alt=""/>
<img src="../../../img/02.jpg" alt=""/>
<img src="../../../img/03.jpg" alt=""/>
</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐