开发者

View all data attached to an element using jQuery's .data()?

开发者 https://www.devze.com 2023-01-16 08:28 出处:网络
If I\'ve attached a number of key-value pairs to a DOM element using .data(), is there any way to iterate them so I can log them in the console?Alternately, is there a way to view this data with a dev

If I've attached a number of key-value pairs to a DOM element using .data(), is there any way to iterate them so I can log them in the console? Alternately, is there a way to view this data with a development tool like Fi开发者_运维知识库reBug? This would be really helpful when debugging a script.


You can call .data() without any parameters, like this:

console.log($("selector").data());

It'll be logged as an object in the console easy to navigate.

0

精彩评论

暂无评论...
验证码 换一张
取 消