Javascript examples for jQuery:Document
Click function was executed every time the document is loaded
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.js"></script> <script type="text/javascript"> $(function(){//w w w . j a v a 2 s .c o m for(var c=1; c<=5; c++){ var btn = $("<button>Button "+c+"</button>"); btn.on('click', function(){ console.log("You click button "+c); }); $("body").append(btn); } }); </script> </head> <body> </body> </html>