日记-2017-7-26-javascript

0726

  • juery 对后加载的 html 内容进行选择

juery 选择器

在这之前需要了解一下 juery 选择器的知识: 选择器

1、普通的事件处理函数

事件

像 click mouseenter 等函数在 html 生成的时候会绑定到文档树上,即,这些函数只会对已有的文档树生效。

比如:


$('button').click(function(){
  alert('click 函数')
})

2、 bind 函数

bind文档

事实上,1 中的函数依赖与 bind 函数,只是简写了形式。


$("button").bind("click",function(){
  alert('bind函数');
});

3、on 函数

on 函数和 bind 函数不同之处在于,on 函数可以对后加载的 html 文档树


$(document).on('click', 'button', function(){
  alert('on 函数')
})

posted @ 2017-07-26 21:38  zx576  阅读(123)  评论(0编辑  收藏  举报