jquery用on代替bind(),live(),delegate()的方法

时间:2023-03-09 14:21:03
jquery用on代替bind(),live(),delegate()的方法

Js的功能确实非常强大,奈何我一个php程序员一直在js上没有投入足够的精力去研究,每次遇到不会的都是去百度,以后有时间真的应该买本书系统的学习一下

// Bind
$( "#members li a" ).on( "click", function( e ) {} );
$( "#members li a" ).bind( "click", function( e ) {} ); // Live
$( document ).on( "click", "#members li a", function( e ) {} );
$( "#members li a" ).live( "click", function( e ) {} ); // Delegate
$( "#members" ).on( "click", "li a", function( e ) {} );
$( "#members" ).delegate( "li a", "click", function( e ) {} );