首页 > Web开发 > 详细

jquery的基本事件

时间:2017-05-25 15:26:12      阅读:295      评论:0      收藏:0      [点我收藏+]
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>jquery事件</title>
<script src="jquery-3.2.0.min.js"></script>
</head>
<body>
<input id="text" value="wet" style="width:200px;height:30px" />
</body>
<script>
/**
* 当元素失去焦点时,执行该事件
*/
$("#text").blur(function(){
console.log($(this).val());
});
/**
*当元素值发生变化的时候,并且失去焦点,执行该事件
*/
$("#text").change(function(){
console.log($(this).val());
})
document.getElementById("text").onchange=function(){
console.log($(this).val());
}
/**
*键盘按下执行事件(一直执行)
*/
$("#text").keydown(function(){
console.log("按下");
})
/**
*键盘弹起执行事件(只执行一次)
*/
$("#text").keyup(function(){
console.log("弹起");
})
/**
* 当窗口改变时,执行该事件(大多数绑定Window)
*/
$(window).resize(function(){
console.log("width:"+$(this).width());
console.log("height:"+$(this).height());
})
/**
*当元素获取焦点时,执行该事件
*/
$("#text").focus(function(){
console.log($(this).val());
})
</script>
</html>

jquery的基本事件

原文:http://www.cnblogs.com/add-really/p/6903812.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!