I need to create 10 buttons dynamically with Jquery and set the text on them to be 1 -10, and add the same click event to all of them.
Should I be using dom create e
$(document).ready(function() { for(i = 1; i <=10; i++) { $('', { text: i, //set text 1 to 10 id: 'btn_'+i, click: function () { alert('hi'); } }); } });
Hope it helps