编辑下面的代码:【加编码】
<html> <head> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("input").select(function(){ $("input").after(" Text marked!"); }); $("#btn1").click(function(){ $("input").trigger("select"); }); $("#btn2").click(function(){ $("input").triggerHandler("select"); }); }); </script> </head> <body> <p>Click each button to see the difference between trigger() and triggerHandler(). <br><br> <input type="text" value="Hello World"> <br><br> <button id="btn1">trigger()</button> <button id="btn2">triggerHandler()</button> </p></body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂