I'm looking to find a more efficient way to build buttons and assign actions to them. The site I'm working with is written entirely in javascript. I tried to implement this:
var test = $('<button/>', {
text: i, //set text 1 to 10
id: 'btn_'+i,
click: function () { alert('hi'); }
});
but I get an error "Uncaught Error: NotFoundError: DOM Exception 8". Does anyone have a terse solution to creating buttons with actions assigned in Javascript? Any help is greatly appreciated.
Thanks!