100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > js触发button的点击事件

js触发button的点击事件

时间:2019-10-08 19:50:35

相关推荐

js触发button的点击事件

1. $(".tab").click(function () { })2. $(".tab").on("click",function () { })3. $(document).on("click", ".tab",function () { })4. 使用<onclick="">触发函数

function load(){//下面两种方法效果是一样的document.getElementById("target").onclick();document.getElementById("target").click();}

$(function(){// test 的点击事件$("#test").click(function(){alert("点击了");});// 调用 test 的点击事件的两种方法$("#test").trigger("click");$("#test").click()})

JQuery绑定click事件的3种写法:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script><script type="text/javascript" src="../js/WdatePicker.js"></script><link rel="stylesheet" type="text/css" href="../css/WdatePicker.css"> <script type="text/javascript">$(document).ready(function(){$("#text").bind("click",function(){alert("我的id为text,你点击时触发");});$("#text1").on("click",function(){alert("hellworl");});$("#text2").click(function(){alert($("#text2").val());});});</script><body><input id="text" type="button" value="点击"/> <input id="text1" type="button" value="点击"/> <input id="text2" type="text" value="love"/> </body></html>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。