jQuery - convert .live() to .on()

后端 未结 4 1973
误落风尘
误落风尘 2020-12-11 05:06

How do I go about combining this old jQuery code into the v1.7 .on()?

v1.3 .live():

    $(\'#results tbody tr\').live({
            


        
4条回答
  •  旧巷少年郎
    2020-12-11 05:40

    The formats used are specified in the documentation for live

    $(document).on({...events...}, selector, data);
    

    -or-

    $(document).on(event, selector, data, callback);
    

    The code for the live function in 1.7+ is now just a pass-through function:

    live: function( types, data, fn ) {
        jQuery( this.context ).on( types, this.selector, data, fn );
        return this;
    }
    

提交回复
热议问题