鼠标连续点击事件--toggle()学习例子

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>鼠标连续点击事件--toggle()</title>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function() {
$("div")
.css("width", "100px")
.css("height", "100px")
.css("background-color", "cornflowerblue")
.toggle( //可以绑定多个点击事件,多个事件之间循环调用
function() {
$("div").html("<h1>你好</h1>");//第一次点击时触发
},
function() {
$("div").html("<h2>你好</h2>");//第2次点击时触发
},
function() {
$("div").html("<h3>你好</h3>");//第3次点击时触发
},
function() {
$("div").html("<h4>你好</h4>");//第4次点击时触发
},
function() {
$("div").html("<h5>你好</h5>");//第5次点击时触发
},
function() {
$("div").html("<h6>你好</h6>");//第6次点击时触发
}
);
});
</script>
</head>
<body>
<div></div>
</body>

posted @ 2018-01-05 13:42  叫我小谷  阅读(1612)  评论(0编辑  收藏  举报