jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
2018-03-01 17:53
369 查看
1.jQuery on()方法是官方推荐的绑定事件的一个方法
例子:
用.on()方法绑定的事件不需要关心注册该事件的元素何时被添加进来,也不需要重复绑定,只要对应的元素添加进页面就可以触发时间。
2.jQuery click方法
用click方法绑定的元素如果是后来加入页面的就不能够触发时间。
3.删除select选中的元素
$(selector).on(event,childSelector,data,function,map)
例子:
$(document).on('click','.resetForm',function(){ $("#live_title").attr("value",""); $("#anchor_id").find("option:selected").removeAttr('selected'); $("#live_type").find("option:selected").removeAttr('selected'); });
用.on()方法绑定的事件不需要关心注册该事件的元素何时被添加进来,也不需要重复绑定,只要对应的元素添加进页面就可以触发时间。
2.jQuery click方法
$('.classname').click(function(){ });
用click方法绑定的元素如果是后来加入页面的就不能够触发时间。
3.删除select选中的元素
$("#anchor_id").find("option:selected").removeAttr('selected');
相关文章推荐
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素
- jQuery on()方法的优点及$().click方法的区别、删除select选中的元素