JQuery和js的单击事件
2012-11-09 22:24
218 查看
jquery的单击事件
对象.cliclk(function(){});
js的单击事件
对象.onclick=function(){}
例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<script type="text/javascript" src="jquery-core/jquery-1.8.0.js"></script>
<script type="text/javascript">
//jquery的单击事件
$(function(){
$('#btn1').click(function(){
alert("您已单击了这个按钮,您已中奖500RMB!");
});
});
//js的单击事件
$(function(){
var btn2 = document.getElementById("btn2");
btn2.onclick=function(){
alert("您已单击了这个按钮,您已中奖600RMB!");
}
});
</script>
</head>
<body>
<input type="button" id="btn1" value="点我试试" />
<input type="button" id="btn2" value="点我试试" />
</body>
</html>
对象.cliclk(function(){});
js的单击事件
对象.onclick=function(){}
例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<script type="text/javascript" src="jquery-core/jquery-1.8.0.js"></script>
<script type="text/javascript">
//jquery的单击事件
$(function(){
$('#btn1').click(function(){
alert("您已单击了这个按钮,您已中奖500RMB!");
});
});
//js的单击事件
$(function(){
var btn2 = document.getElementById("btn2");
btn2.onclick=function(){
alert("您已单击了这个按钮,您已中奖600RMB!");
}
});
</script>
</head>
<body>
<input type="button" id="btn1" value="点我试试" />
<input type="button" id="btn2" value="点我试试" />
</body>
</html>
相关文章推荐
- 用js,jQuery屏蔽鼠标右与jquery 鼠标右键事件、左键单击事件判定
- jQuery与js绑定事件的几种写法(以单击事件示例)
- js和jQuery对应的单击事件的写法
- (转)js,jQuery屏蔽鼠标右与jquery 鼠标右键事件、左键单击事件判定
- 不要再吹水地球人听不懂的技术,咱来点干货!--中文前端UI框架Kit(四)给你真正的原生的drag以及drop事件,而不是像市面上主流的Js框架jQuery,Ext等,利用mousemove事件,判断位置来模拟
- jquery textSearch实现页面搜索 注意!!!!调用这个插件后,js事件绑定如,on、bind、live delegate全部失效,折腾了我一整天!!!
- jquery 全选、反选、各行换色、单击行选中事件
- jquery.js 库中的 选择器 的 事件的绑定
- jQuery.tap.js插件tap事件执行两次问题
- jquery为js做的鼠标点击事件
- 简单介绍JS/JQuery绑定事件的几种方式
- js事件委托和jQuery事件绑定on , off , one , bind , unbind , die
- jquery的主要事件--单击双击,焦点,悬停
- js区分鼠标单击和双击事件
- jquery学习笔记-jQuery实现单击和鼠标感应事件
- 使用JS或jQuery模拟鼠标点击a标签事件
- 用jQuery的ajax加载的内容无法触发单击事件
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器)
- JS及jQuery获取各种宽度、高度的简单介绍以及判断滚动条滚动到底部事件