jquery的单击事件
对象.cliclk(function(){});
js的单击事件
对象.οnclick=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.οnclick=function(){
alert("您已单击了这个按钮,您已中奖600RMB!");
}
});
</script>
</head>
<body>
<input type="button" id="btn1" value="点我试试" />
<input type="button" id="btn2" value="点我试试" />
</body>
</html>
对象.cliclk(function(){});
js的单击事件
对象.οnclick=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.οnclick=function(){
alert("您已单击了这个按钮,您已中奖600RMB!");
}
});
</script>
</head>
<body>
<input type="button" id="btn1" value="点我试试" />
<input type="button" id="btn2" value="点我试试" />
</body>
</html>