I am creating buttons dynamically using jQuery:
function createRefreshButton() {
var $btn = $('<button/>', {
text: 'Refresh Data',
id: 'btn_refresh'
});
$($btn).on('click', function () {
ClickRefresh()
});
return $btn;
}
I was wondering if it is possible to change this code to something like this:
function createRefreshButton() {
var $btn = $('<button/>', {
text: 'Refresh Data',
id: 'btn_refresh',
onclick: 'ClickRefresh()'
});
return $btn;
}
However nothing happens when I click the button with that syntax. Is that due to errors in my suggested code or is it simply impossible? Thank you in advance.