美文网首页
jQuery中的.on()改写.bind()、.live()、.

jQuery中的.on()改写.bind()、.live()、.

作者: 九又四分之三o | 来源:发表于2017-09-22 09:30 被阅读0次
    /* The jQuery .bind(), .live(), and .delegate() methods are just one 
       line pass throughs to the new jQuery 1.8.2 .on() method */
    
    // 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 ) {} );
    

    相关文章

      网友评论

          本文标题:jQuery中的.on()改写.bind()、.live()、.

          本文链接:https://www.haomeiwen.com/subject/uckeqxtx.html