.live() vs .Click()

jquery

#1

Which one is preferred $(’#id).live(‘click’, function(){});
or $(’#id’).click(function(){}); ?
Please provide preferred scenarios for both syntax usage?


#2

These two are used for different scenarios.

If your data is not loaded dynamically and you are sure that it will be available when you are binding click event to it you can use - $(’#id’).click(function(){});

But if it is not present at the time of binding click event then you will have to use $(’#id).live(‘click’, function(){});

Also .live is not supported in latest jQuery so you must use .on(“click”) in place of .live(“click”)