I am using jquery 1.10. I want to know what the difference is between these three functions.
Which function is better and why?
What is the purpose of the del
$(".dropdown-menu").on("click", ".show_opt_menu", function() {
alert("hello");
});
this function attaches click event to .dropdown-menu executes when the target element is .show_opt_menu that means when you dynamically add another .show_opt_menu dont need to attach click function. the parent is responsible for the click action.
$(".dropdown-menu .show_opt_menu").on("click", function() {
alert("hello");
});
this function attaches the click event to .show_opt_menu so when you dynamically add new .show_opt_menu you need to attach event separately to that.
$(".dropdown-menu").delegate(".show_opt_menu", "click", function() {
alert("Delegate");
});
same purpose of on