Tuesday, August 13, 2013

New JQuery Live Notations

Jquery recently change the notations for the new versions, please find the new jquery live function notations bellow.

Old Jquery Live 



$("a.offsite").live("click", function(){ alert("Goodbye!"); }); // jQuery 1.3+
$(document).delegate("a.offsite", "click", function(){ alert("Goodbye!"); }); // jQuery 1.4.3+
$(document).on("click", "a.offsite", function(){ alert("Goodbye!"); });

New Jquery Live


$(function(){
    $(document).on('click', '.sm2_expander', function(){
        alert('bye');
        $(this).parent().parent().toggleClass('sm2_liOpen').toggleClass('sm2_d');
    })
})

$(function(){
    $(document).on('click', '.sm2_expander', function(){
        $(this).closest('li').toggleClass('sm2_liOpen sm2_liClosed');
    })
})

If you have any questions just comment bellow.