<!DOCTYPE html> <html> <head> <script type="text/javascript" src="lib/jquery-3.4.1.min.js" defer></script> <script type="text/javascript" src="js/index.js" defer></script> </head> <body> <div id="append"></div> </body> </html>JS:
$('#append').append('<a href="#" class="apendTest">Test</a>'); $('#append').on('click', '.apendTest', function() { alert("test") })