且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javascript $(this).data()不起作用

更新时间:2022-12-18 10:33:37

当你使用 data() api,无需使用数据 - 前缀来读取 data - * 属性值 - 请参阅 data-html5

When you use the data() api, there is no need to have the data- prefix to read the data-* attribute value - see data-html5

var status = $(this).data('pid');

如果您使用 .attr()然后你需要使用完整的属性名称,如

If you are using .attr() then you need to use the complete attribute name like

var status = $(this).attr('data-pid');