Ultimate Web Tips

your Wordpress, jQuery, PHP, MySQL, Linux and CSS guide to a successful website
Read more:
Posts Tagged ‘.live()’

jQuery has two API methods that provide similar event delegation functionality: live and delegate. Event delegation is a powerful technique that is often used in JavaScript applications. On the surface live and delegate can seem interchangeable. However, they are not. Live has several serious disadvantages and should never be used, and this article will explain why.

This is probably the first thing to learn about jQuery. Everything inside the $(document).ready() function will execute as soon as the DOM is registered by the browser and before the page contents are loaded. So if you want an event to work, call it inside this handler. This means that everything you stick inside the brackets is ready to go at the earliest possible moment, which allows hiding and showing effects and other dynamic functionality when the user sees the page elements.