Alex Rivera | Logout

jQuery attribute auto added to elements

Asked 2010-05-03T19:41:25.203
13

After using the IE8 built in Developers Tools for the first time, I noticed jQuery is attaching an attribute to some of my elements: alt text http://thebe.jtan.com/~vince/stack/jquery.PNG

I've never noticed this before. In fact, this doesn't show up in Firebug... I'm only seeing it for the first time now in IE8 Developer Tools. Does anyone know what jQuery uses this for, and why it's hidden in firebug?

Edit
Report

2 Answers

4

jQuery uses this "expando" to bind data and events to objects. It looks like it works along with a data and event cache. I'd love to hear a more in-depth explanation, though.

answered 2010-05-03T20:02:07.510
0

If you use jQuery’s .html() method to find a string of HTML, beware if that HTML contains any elements that have events registered—you might get a little more than you bargained for.

Don’t depend on .html() for well-formed XML snippets.

My quick fix was to change the order of business. I simply did my jQuery event binding after the data had been sent. A hard lesson learned, then, in view of the amount of time I spent tearing my hair out, but an important one nonetheless.

I am guessing your are using 1.3.1 which the issue has been fixed in later versions. So just update and probabaly you will be fine.

answered 2010-05-03T20:06:00.247

Your Answer