jQuery基础事件-绑定事件
来源:互联网 发布:阿里云免费半年邀请码 编辑:程序博客网 时间:2024/05/18 03:45
js中的事件
click,dblclick,mousedown,mouseup,mousemove,mouseout,change,
select,submit,keydown,keypress,keyup,blur,focus,load,resize,scroll,
error
1.绑定事件
2.简写事件
3.复合事件
//绑定事件
/**
$(function(){
$('input').bind('click',function(){
alert('click事件');
});//利用bind方法绑定,两个参数,第一个为事件类型,第二个是事件
})
*/
//事件方法和绑定分离,方法在自己定义
/**
$(function(){
function fun(){//自己定义的函数
alert('点击绑定的事件');
}
$('input').bind('click',fun);//绑定到事件上
})
*/
//绑定多个事件
/**
$(function(){
$('input').bind('mouseover mouseout',function(){
alert('move');
});
})
*/
//分开绑定事件
/**
$(function(){
$('input').bind({
mouseover:function(){
alert('mouseover');
},
mouseout:function(){
alert('mouseout');
}
});
})
*/
//解绑
/**
$(function(){
$('input').bind({
mouseover:function(){
alert('mouseover');
},
mouseout:function(){
alert('mouseout');
}
});
//$('input').unbind();//解绑所有绑定的事件
//$('input').unbind('mouseover mouseout');//传递一个要解绑的事件类型,也可以传递多个
})
*/
/**
$(function(){
function fun1(){
alert('fun1');
}
function fun2(){
alert('fun2');
}
$('input').bind('click',fun1);//绑定事件fun1
$('input').bind('click',fun2);//绑定事件fun2
$('input').unbind('click',fun1);//解绑指定的事件
})
*/
//事件绑定简写
/**
$(function(){
/**$('input').click(function (argument) {
alert('click');
});
*/
/**
$('input').mousedown(function (argument) {
alert('mousedown');
})
*/
/**
$('input').mouseleave(function (argument) {
// body...
alert('mouseleave');
})
*/
/**
$(window).resize(function (argument) {
// body...
alert('size change');
})
*/
/**
$(window).scroll(function (argument) {
// body...
alert('scroll');
})
*/
/**
$('input').select(function (argument) {//select是当选中文本内时触发事件
// body...
alert('select');
})
*/
/**
$('input').change(function (argument) {//当文本中的内容被改变时触发事件
// body...
alert('change');
})
*/
/**
$('form').submit(function (argument) {//submit事件绑定在form上,而不是input上
// body...
alert('submit');
})
*/
//})
click,dblclick,mousedown,mouseup,mousemove,mouseout,change,
select,submit,keydown,keypress,keyup,blur,focus,load,resize,scroll,
error
1.绑定事件
2.简写事件
3.复合事件
//绑定事件
/**
$(function(){
$('input').bind('click',function(){
alert('click事件');
});//利用bind方法绑定,两个参数,第一个为事件类型,第二个是事件
})
*/
//事件方法和绑定分离,方法在自己定义
/**
$(function(){
function fun(){//自己定义的函数
alert('点击绑定的事件');
}
$('input').bind('click',fun);//绑定到事件上
})
*/
//绑定多个事件
/**
$(function(){
$('input').bind('mouseover mouseout',function(){
alert('move');
});
})
*/
//分开绑定事件
/**
$(function(){
$('input').bind({
mouseover:function(){
alert('mouseover');
},
mouseout:function(){
alert('mouseout');
}
});
})
*/
//解绑
/**
$(function(){
$('input').bind({
mouseover:function(){
alert('mouseover');
},
mouseout:function(){
alert('mouseout');
}
});
//$('input').unbind();//解绑所有绑定的事件
//$('input').unbind('mouseover mouseout');//传递一个要解绑的事件类型,也可以传递多个
})
*/
/**
$(function(){
function fun1(){
alert('fun1');
}
function fun2(){
alert('fun2');
}
$('input').bind('click',fun1);//绑定事件fun1
$('input').bind('click',fun2);//绑定事件fun2
$('input').unbind('click',fun1);//解绑指定的事件
})
*/
//事件绑定简写
/**
$(function(){
/**$('input').click(function (argument) {
alert('click');
});
*/
/**
$('input').mousedown(function (argument) {
alert('mousedown');
})
*/
/**
$('input').mouseleave(function (argument) {
// body...
alert('mouseleave');
})
*/
/**
$(window).resize(function (argument) {
// body...
alert('size change');
})
*/
/**
$(window).scroll(function (argument) {
// body...
alert('scroll');
})
*/
/**
$('input').select(function (argument) {//select是当选中文本内时触发事件
// body...
alert('select');
})
*/
/**
$('input').change(function (argument) {//当文本中的内容被改变时触发事件
// body...
alert('change');
})
*/
/**
$('form').submit(function (argument) {//submit事件绑定在form上,而不是input上
// body...
alert('submit');
})
*/
//})
阅读全文
1 0
- jQuery基础事件-绑定事件
- jQuery基础----04jQuery选择器和事件-事件之绑定、解除绑定事件
- jquery事件与绑定事件
- jquery事件与绑定事件
- jquery事件与绑定事件
- jquery事件与绑定事件
- jquery事件与绑定事件
- jquery事件篇-事件绑定
- JQuery 绑定变化事件
- jQuery 中的事件绑定
- jquery 绑定事件
- jquery 事件绑定
- Jquery控件绑定事件
- jQuery 特殊事件绑定
- jquery 绑定click事件
- jQuery的绑定事件
- jQuery事件绑定.on()
- JQuery事件绑定
- activity被系统回收onDestory会不会在执行以及如何恢复
- 网络编程UDP
- 格式转换工具PDF Extractor SDK更新至v8.6.0.2911,修复对比度预处理过滤器
- 分享一个ds12c887的在1602上显示的52单片机的程序
- Excel使用VBA读取实时WebService股票数据
- jQuery基础事件-绑定事件
- c++ stl容器vector删除(erase),遍历等基本用法介绍及头文件
- vue axios全攻略
- SSM的项目搭建
- Unit 7
- nginx安装和使用
- Uncaught SyntaxError: Unexpected end of input 解决办法
- cout进行输出时为啥不加endl,也能立即显示输出内容?
- java操作xml之dom4j中的xpath实现用户登陆验证