The binding of event handlers are the most confusing part of jQuery for many developers working on jQuery projects. Many of them unsure of which is better to use. In this article we will see the main differences between Bind and Live methods in jQuery.
Bind() Method
The bind method will only bind event handlers for currently existing items. That means this works for the current element.
Example
$(document).ready(function () {
$('P').bind('click', function () {
alert("Example of Bind Method");
e.preventDefault();
});
});
Live() Method
The Live method can bind event handlers for currently existing items or future items.
Example
$(document).ready(function() {
$('P').live('click', function() {
alert("Example of live method");
e.preventDefault();
});
$('body').append('<p>Adding Future items</p>');
});
Posted Date:- 2021-09-01 05:10:00
How jQuery stores data related to an element?
What is the difference between jQuery.get() and jQuery.ajax() ?
What is Method Chaining in jQuery? What advantages does it offer?
What is the use of the val() method in jQuery?
What is the use of the serialize() method in jQuery?
Describe the functionality of read cookies, write cookies and delete cookies in jQuery.
Differentiate between width() vs css(‘width’) in jQuery.
What is jQuery Effects - Fading?
What is jQuery UI Sortable and how to use it?
How to add and remove CSS classes to an element using jQuery?
What is the use of the toggle() method in JQuery?
Difference between prop and attr?
What are all the ways to include jQuery on a page?
What is the difference between Map and Grep function in jQuery?
List the four parameters used for the jQuery Ajax method.
Can you give some situations or scenarios for using jQuery?
Can I use a jQuery library for server scripting?
Identify any difference between .detach() and .remove() of jQuery.
Explain any of the advantages of hosting a jQuery from CDN.
What is queue() in Jquery? Use of queue() in jquery?
What is jQuery Datepicker in jQuery?
What is the use of html() method in JQuery?
Explain the functionality of jQuery UI (user interface).
Differentiate between jquery.min.js and jquery.js
Explain the Applications for jQuery Mobile.
What are the four parameters used for the jQuery Ajax method?
Briefly explain the bootstrap and JavaScript plug-in.
Differentiate between the ID and Class selector in jQuery.
What is the difference between $(window).load and $(document).ready function in jQuery?
What is the difference between bind() vs live() vs delegate() methods in jQuery?
Differentiate among .empty() vs .remove() vs .detach() in jQuery.
Explain the difference between the .detach() and remove() methods in jQuery.
What is the advantage of hosting a jQuery using a CDN?
What is a Data Table plug-in for jQuery?
Is it possible that jQuery HTML works for both HTML and XML documents?
What is the difference between jquery.min.js and jquery.js?
What is the difference between onload() and document.ready() methods?
Define jQuery UI Autocomplete ?
What $(document).ready(function()) is and when to use it?
What is the history of jQuery UI and how to use it?
What is the usage of Draggable, Droppable, Resizable, Selectable in jQuery UI?
Define Add or Remove class in jQuery?
What is resize() function in jQuery?
What is the difference between bind() and live() method in jQuery ?