<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JQ-事件-2</title>
<script src="jquery.min.js" type="text/javascript"></script>
<style>
.hh{
width:100px;
height:100px;
background:#3C0;
}
</style>
</head>
<body>
<div id="ck">点我</div>
<div class="hh" id="hov">飘过来~!</div>
<input name="" type="text" id="textBox" />
<script>
$(function(){
//on事件
$("#ck").on("click",function(){
$("body").append($(this).clone());
alert($(this).text());
});
//hover事件
$("#hov").hover(
function(){
$(this).css("background","red");
},
function(){
$(this).css("background","blue")
}
);
//focus事件
$("#textBox").focus(function(){
$("#hov").text("飘过来")
})
//blur事件
$("#textBox").blur(function(){
$("#hov").text("飘回去")
$("#textBox").append("请输入名字!");
})
$("#textBox").change(function(){
$(this).append("请输入名字!");
})
})
</script>
</body>
</html>
JQ-事件-2
最新推荐文章于 2022-06-06 12:00:33 发布