標籤: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方法的使用