jQuery:
$(".close_invoice").confirm({
title: 'Are you sure to delete it?',
content: 'Click to Delete if you are sure else click on Close.',
type: 'red',
typeAnimated: true,
buttons: {
delete: {
text: 'Delete',
btnClass: 'btn-red',
action: function() {
alert($(this).attr("id"));
}
},
close: {
text: 'Close',
btnClass: 'btn-blue',
action: function() {}
}
}
});
HTML:
<button class="btn btn-sm green btn-outline filter-submit margin-bottom close_invoice" id="14" jc-attached="true"><i class="fa fa-times"></i> Close Invoice</button>
Anyone can please tell me Why it not taking the value of attribute ID. How can I get the value of attribute ID? It alerting undefined.
console.log(this);. Because it can be a scope problem. And please tell me what ".confirm()" function is, bootbox plugin?thismight be referencing to something else. Did you try debugging? Or can you post a snippet/fiddle?id="14"in html but in js you have to call like thisalert($(this).attr("#14"));.