Javascript examples for jQuery:Link
Append li with a link with a custom click event
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(window).load(function(){// w w w . ja v a2s . c o m $('#myid ul').append("<li><a href=''>Link</a></li>"); $("a").live("click", function() { console.log('hi'); }); }); </script> </head> <body> <div id="myid"> <ul></ul> </div> </body> </html>