I have an object with a function inside of it but i can't get the function to execute on click
This is the fiddle https://jsfiddle.net/tgxu7rpv/23/
and this is the code
$(document).ready(function () {
MyObject = {
ae: function(clicked_id) {
var items = JSON.parse(localStorage.getItem('entry'));
if (items == null || typeof items !== 'object') {
items = [];
}
var entry = {
'num': clicked_id
};
items.push(entry);
localStorage.setItem('entry', JSON.stringify(items));
alert(localStorage.getItem('entry'));
var fromStorage = localStorage.getItem('entry');
for (var data in fromStorage) {
alert("Value" + fromStorage[data]);
}
}
};
$(document).on('click', '.btn-primary', function(){
$('.table tbody').append('<tr class="child"><td>one</td><td><button id="num" onClick="MyObject.ae(this.id);" type="button" class="invite ">Invite</button></td></tr>');
});
});
I can't call the function onClick="MyObject.ae(this.id);"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.