This is weird behavior but when I am trying to access some data attribute using jQuery data() function, it is returning me undefined but attr() is returning me the actual value. I know data works differently as it caches for the first time and then it retrieves from cache. I am using jQuery 1.4.2 and then tried looking with jQuery 1.7.1 and it did work. But I can't upgrade to 1.7.1 at the moment. Any thoughts on it??
I will appreciate any kind of suggestion or help provided
HTML5 data-*
objects being pulled into .data
was not done until jQuery 1.4.3: http://api.jquery.com/data/#data-html5
Maybe you can just update to 1.4.3?
You answered your own question: data
doesn't work in jQuery 1.4.2. If you can't upgrade, you try this plugin .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.