查找:

  • children:     find(selector), children(selector);
  • parent:       parent(), parents(selector), closest(selector)  //最近的上层
  • find()
    • $("#main li");$("#main > li");    --->      $("#main").find("li");$("#main").children('li');
  • first()/last()
    • $("#main li:first")                     --->      $("main").find("li").first();  /last()
  • filter()
    • $("#main.onsale");                   --->       $("#main").filter(".onsale");

 绑定:

  • on(

    • $("button").click(function(event) {});    --->     $("button").on("click",function() {});

  • after()   //与remove一起用节点替换

    • --->

        $("#div").on("click","button",function() {
      var message = "<span>click now!</span>";
      $(this).after(message).remove();
      });
  • data()   //HTML5属性,适用于文本的设置替换

     <div  data-title="use data">
    <button id="set">set</button>
    <button id="get">get</button>
    </div>
    ----------------------------------
    $("#set").on("click",function() {
    $(this).parent().data("title","data has changed");
    });
    $("#get").on("click",function() {
    $(this).after($(this).parent().data("title")).remove();
    });
  • 使用namespace和off()
    //of()
    -------------------------
    $("#btn1").on("click",picture);
    $("#btn1").on("click",status);
    $("#btn1").off("click"); //namespace
    --------------------------
    $("#btn2").on("click.pic",picture);
    $("#btn2").on("click.stat",status);
    $("#btn2").off("click.pic"); $("#btn3").on("click.pic",picture);
    $("#btn3").on("click.stat",status);
    $("#btn3").on("mouseover.stat",status);
    $("#btn3").off(".stat");
  • 使用trigger  //触发
    $("#btn4").on("click",function() {
    $("#btn2").trigger("click");
    }); $("div").on("exam.new",function() { //自定义
    console.log($(this).data());
    });
    $("#btn5").on("click.pict",function() {
    picture();
    $("div").trigger("exam.new");
    });

事件:

  • keyboard events:  keypress,keydown,keyup;
  • form events:        focus,blur,change,select,submit;
  • mouse events:     click,dbclick,focusin,focusout,mousedowm,mouseup,mousemove,mouseout,mouseover,mouseleave,mouseenter;

节点与方法连接

function Confirmation(ele) {
this.ele = ele;
this.ticket = this.ele.find(".ticket");
var confirmation = this;
this.loadConfirmation = function() {
$.ajax("confirmation.html", {
timeoOut: 3000,
context: confirmation,//"this" in the function;
success: function(res) {
this.ticket.html(res).slideDown();
}
});
this.showBoardingPass = function(event) {
event.preventDefault();
$(this).hide();
confirmation.find(".boarding-pass").show();
};
this.ele.on("click","button",this.loadConfirmation);
this.ele.on("click","view-boarding-pass",this.showBoardingPass);
}
}
$(function() {
var paris = new Confirmation($("#paris"));
var london = new Confirmation($("#london"));
});

  

  

最新文章

  1. angular开发者吐槽react+redux的复杂:“一个demo证明你的开发效率低下”
  2. Android 手机卫士--md5加密过程
  3. android Menu
  4. Enterprise Library +Caliburn.Micro+WPF CM框架下使用企业库验证,验证某一个属性,整个页面的文本框都变红的原因
  5. 我认为测试应该掌握的SQL语句
  6. Tesseract训练笔记
  7. Windows server 2008 R2远程桌面终端连接数的破解
  8. posix thread API列表
  9. (转载)Windows 7 Ultimate(旗舰版)SP1 32/64位官方原版下载(2011年5月12日更新版)
  10. 解决android启动程序时,会出现一个短暂的白色空白界面的问题
  11. 自动输入用户名和密码用于telnet的shell
  12. 【HotSpot】 jps
  13. python 元祖字典集合
  14. 如何加入Microsoft Teams 技术社区
  15. CentOS 7下升级Python版本到3.x系列
  16. 【待补充】[HDFS_3] HDFS 工作机制
  17. MathType怎么编辑半开半闭区间
  18. POJ - 1101 The Game dfs
  19. python其他知识目录
  20. js for form

热门文章

  1. C# 我理解的接口、抽象类、以及事件
  2. 二分图最大匹配的K&amp;#246;nig定理及其证明
  3. 通过IIS调试ASP.NET项目
  4. sizeof()和strlen()的区别与联系
  5. poj1611(感染病患者)
  6. HTML5/CSS3开发工具
  7. linux里的vi怎么移动到最后一行
  8. 【Python】Django 时间字段 最佳实践
  9. Solr5.3.1 SolrJ查询索引结果
  10. Linux下配置JDK