Javascript examples for jQuery:Link
set handlers to all links with real href
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> <script type="text/javascript"> $(window).load(function(){/* w ww .j a v a2 s. c o m*/ $('body').append('<a href="http://www.java2s.com"> test </a> | <a href="#"> asdf </a>'); $('body').on('click', 'a:not([href="#"])', function(e){ e.preventDefault(); console.log('here'); }); }); </script> </head> <body> </body> </html>