jQuery 1.9 .live() is not a function

前端 未结 10 1085
再見小時候
再見小時候 2020-11-22 03:46

I recently updated jQuery from 1.8 to 2.1. I suddenly discovered that the .live() stops working.
I get the error TypeError: $(...).live is not a funct

10条回答
  •  被撕碎了的回忆
    2020-11-22 04:24

    When i will getting this error on my site .it will stop some functionality on my site, after research i find the solution for this problem ,

    $colorpicker_inputs.live('focus', function(e) {
        jQuery(this).next('.farb-popup').show();
        jQuery(this).parents('li').css( {
            position : 'relative',
            zIndex : '9999'
        })
        jQuery('#tabber').css( {
            overflow : 'visible'
        });
    });
    
    $colorpicker_inputs.live('blur', function(e) {
        jQuery(this).next('.farb-popup').hide();
        jQuery(this).parents('li').css( {
            zIndex : '0'
        })
    });
    

    Should be replace 'live' to 'on' check below

        $colorpicker_inputs.on('focus', function(e) {
        jQuery(this).next('.farb-popup').show();
        jQuery(this).parents('li').css( {
            position : 'relative',
            zIndex : '9999'
        })
        jQuery('#tabber').css( {
            overflow : 'visible'
        });
    });
    
    $colorpicker_inputs.on('blur', function(e) {
        jQuery(this).next('.farb-popup').hide();
        jQuery(this).parents('li').css( {
            zIndex : '0'
        })
    });
    

    One more basic exmaple below :

    .live(event, selector, function) 
    

    Change it to :

    .on(event, selector, function)
    

提交回复
热议问题