本文摘自PHP中文网,作者coldplay.xixi,侵删。
JQuery click()和onclick()区别:1、onclick是绑定事件,告诉浏览器在鼠标点击时候要做什么;2、click方法的主要作用是触发调用click方法元素onclick事件。
本教程操作环境:windows7系统、jquery1.10.0版,该方法适用于所有品牌电脑。
JQuery click()和onclick()区别:
1、onclick是绑定事件,告诉浏览器在鼠标点击时候要做什么
2、click()方法的主要作用是触发调用click方法元素onclick事件。
3、当click()被点击时,首先执行的是对应元素的onclick()函数,然后再是click(),示例如下:
JS代码 test.js:
1 2 3 4 5 6 | $( "#testclick" ).click( function (){
console.log( "$(\"#testclick\").click" );
});
function test123(){
console.log( "function test()" );
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <!DOCTYPE html>
<html>
<head>
<title>TestJS.html</title>
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >
<meta http-equiv= "description" content= "this is my page" >
<meta http-equiv= "content-type" content= "text/html; charset=UTF-8" >
<!--<link rel= "stylesheet" type= "text/css" href= "./styles.css" >-->
</head>
<body>
This is my HTML page. <br>
<h1>Test html</h3>
<div>
<input type= "button" onclick= "test123();" class = "input1" id= "testclick" value= "test_button" />
</div>
<!-- JS-->
<script src= "js/lib/jquery.js" ></script>
<script src= "js/test.js" ></script>
<!-- <script src= "js/test2.js" ></script> -->
</body>
</html>
|
相关学习推荐:javascript视频教程
以上就是JQuery click()和onclick()区别是什么的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
jQuery对象和dom对象之间的差异
jQuery如何设置按钮不可用
jQuery是否获得焦点
jQuery怎样才能确定滚动事件的方向
jQuery中on()与click()的区别是什么?
jQuery怎么判断是否是ie浏览器
jQuery有哪些表单选择器
基于jQuery和html5的日历时钟插件 的图文详解
jQuery怎么判断input是否为空
jQuery如何判断元素中是否存在标签
更多相关阅读请进入《jQuery》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » JQuery click()和onclick()区别是什么