I can use the jquery .data attribute and an alert confirms that it worked, but I don't see data attribute in page using firebug.
$('#something').data('foo', 52);
alert($('#something').data('foo'));
The jQuery .is ( “:visible”) method is used to detect whether a specific element in the page is visible or not. This is a built in method in jQuery, the “:visible” is the CSS selector that selects the specific visible element.
It can't find every event because there's no standard way to look up what event handlers are attached to an element, but it works with popular libraries like jQuery, Prototype, MooTools, YUI, etc. Show activity on this post. You could use FireQuery. It shows any events attached to DOM elements in the Firebug's HTML tab.
Within the Firefox Developer Tools' Inspector panel lists all events bound to an element. First select an element with Ctrl + Shift + C, e.g. Stack Overflow's upvote arrow. Click on the ev icon to the right of the element, and a dialogue opens:
I also found jQuery Debugger in the chrome store. You can click on a dom item and it will show all events bound to it along with the callback function. I was debugging an application where events weren't being removed properly and this helped me track it down in minutes.
The information put into .data(...)
is not a visible DOM attribute.
You can view an object's data by doing console.log($('#something').data());
Demo: http://jsfiddle.net/maniator/pQybU/
jQuery doesn't actually add a data attribute as such to the element and so there is nothing in the DOM that firebug can display.
As Neal points out you can log the data to console to verify that it is in fact there.
Alternatively you can install a Firebug extension such as FireQuery (http://firequery.binaryage.com/) to directly display jQuery data in Firebug itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With