user1032531
user1032531

Reputation: 26281

How to view jquery data() using Firefox/Firebug or other browser

I usually use firebug to troubleshoot JavaScript.

Other than inserting script like I did below, is there an easy way to view jQuery data() associated with an element using Firefox/Firebug? I am open to other tools such as Chrome if necessary.

<div id='foo' data-bar='hello'></div>
...
$('#foo').data('bar','goodby');
...
console.log($('#foo').data('bar'));

Upvotes: 3

Views: 259

Answers (2)

user3570283
user3570283

Reputation: 13

Method I use is in Chrome. F12, Sources, put break point in your function, hover over the variable with your cursor to see what its passing/returning.

http://www.codeproject.com/KB/trace/BeginChromeDebug/view_watch.png

Upvotes: 0

edcs
edcs

Reputation: 3879

You can enter JavaScript into most debugging consoles; if you type in your code and press enter you will see it's output beneath, like so:

Google Chrome JavaScript Console

The above example is from Chrome.

Upvotes: 1

Related Questions