As of jQuery 1.7 .live deprecated and replaced with .on . However, it is hard for me to get jQuery .on to work with event.preventDefault(); . In the example below, clicking the anchor tag leads me to the linked page, rather than preventing the default browser from following the link.
jQuery('.link-container a').on('click', function(event) { event.preventDefault();
However, the same code with .live works without any hiccups.
jQuery('.link-container a').live('click', function(event) { event.preventDefault();
I am using jQuery version 1.7.1, which comes with Wordpress 3.3.1. What am I wrong here?
source share