jQuery Live Bind

联合创作 · 2023-10-02 15:28

Using $.fn.is_match(selector) to build a live bind method:

sample:
<div class="kkkk">
<div class="ppp1" title="333">hello1</div>
</div>
<script>
  function alr(){alert(this.innerHTML);}
  function alr1(){alert('hello:'+this.innerHTML);}
  $.live_bind(".kkkk  .ppp1 + .ppp[title='333']", 'click', alr);
  $.live_bind(".kkkk  .ppp[title='333']:nth-child(3)", 'click', alr1);
  //"tr:eq(3)" should be "tr:nth-child(4)"
  //"tr:gt(3)" should be "tr:nth-child(4) ~ tr"
  //"tr:gt(0)" could be "tr:not(:first-child)"
  //"tr:first" should be "tr:first-child"
  $('.kkkk').append('<div class="ppp" title="333">hello</div>');
  $('.kkkk').append('<div class="ppp" title="333">jack</div>');
</script>
浏览 6
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报