Is it possible to view jQuery added data in Chrome

亡梦爱人 提交于 2019-12-02 21:47:35

Open the inspector, and into the console, type

$('<some selector>').data()

and then hit return to evaluate the data() method and show its return value directly.

There's no need to use console.log unless you're calling it within non-interactive code.

Chrome Query

Can be found in the Chrome Extensions Webstore and adds another tab to the properties panel in the developer tools.

Type into the chrome console:

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

and it will list the data in that element

jdavid.net

For this reason, I don't use the $(selector).data() pattern, and, instead I use a more HTML natural $(selector).attr('data-name','value') which adds the values to the actual HTML.

$(selector).attr('data-name','value') does not work in IE8+ browsers. .data() is preferred. Also, a user defined var such as say: data-name is not an attribute in HTML.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!