本教程操作环境:windows7系统、jquery1.10.2版本、Dell G3电脑。
jquery实现点击翻转效果的方法
1、设置点击事件
利用click()给元素绑定点击事件,并设置事件处理函数
复制代码1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
.block {
width: 200px;
height: 200px;
background: brown;
cursor: pointer;
transition: 0.8s;
}
</style>
<script src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("button").click(function() {
//点击事件发生后,执行的代码
});
});
</script>
</head>
<body>
<div class="block"></div><br>
<button>翻转元素</button>
</body>
</html>
登录后复制
2、在事件处理函数中,使用css()给指定元素添加翻转样式
css() 方法返回或设置匹配的元素的一个或多个样式属性。
翻转样式为“transform: rotateY(180deg)
”
复制代码1
2
3
4
5
$(document).ready(function() {
$("button").click(function() {
$("div").css("transform","rotateY(180deg)");
});
});
登录后复制
【推荐学习:jQuery视频教程、web前端视频】
以上就是jquery怎么实现点击翻转效果的详细内容,更多请关注靠谱客其它相关文章!
最后
以上就是唠叨棒球最近收集整理的关于jquery怎么实现点击翻转效果的全部内容,更多相关jquery怎么实现点击翻转效果内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复