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>
任何人都可以告诉我为什么它不采用属性 ID 的值。如何获取属性 ID 的值?它警告未定义。
最佳答案
您不能在函数对象参数
中使用this
选择器。您可以将此值
保存到一个变量中,然后将其作为函数参数对象的值
关于javascript - jQuery 没有获取属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46986564/