码迷,mamicode.com
首页 > Web开发 > 详细

关于jQuery中的trigger和triggerHandler方法的使用

时间:2017-08-04 18:23:29      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:file   head   cti   pos   handler   rac   javascrip   art   value   

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>设计器</title>
	<script name="systemJs" type="text/javascript" src="../../zhuant-design/js/jquery-1.11.3.min.js"></script>
</head>
<body>
	<button id="old">.trigger("focus")</button>
    <button id="new">.triggerHandler("focus")</button><br/><br/>
    <input type="text" value="To Be Focused"/>
	
	<br>
	<span id="content">这是内容</span>
    <ul>
	    <li>test1</li>
		<li>test1</li>
		<li>test1</li>
	</ul>
	
	
	<script type="text/javascript">
		$("#old").click(function(){
		  $("input").trigger("focus");
		});
		$("#new").click(function(){
		  $("input").triggerHandler("focus");
		});
		$("input").focus(function(){
		  $("<span>Focused!</span>").appendTo("body").fadeOut(1000);
		});
		
		
		$("li").click(function(){
		    $("#content").triggerHandler("getContent");
		});
		$("#content").bind("getContent",function(){
		     alert($(this).text());
		});
	</script>
</body>
</html>

关于jQuery中的trigger和triggerHandler方法的使用

标签:file   head   cti   pos   handler   rac   javascrip   art   value   

原文地址:http://www.cnblogs.com/mthoutai/p/7286365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!