简体   繁体   English

jQuery 没有获取属性值

[英]jQuery not getting attribute value

jQuery: 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: 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.任何人都可以告诉我为什么它不采用属性 ID 的值。 How can I get the value of attribute ID?如何获取属性 ID 的值? It alerting undefined.它警告未定义。

你不能在function object parameters使用this选择器..你可以把这个value保存到一个变量中,然后把它作为function paramater object's value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM