Menu icon Foundation

My Posts

No Content

My Comments

tenshi13 commented on Bruno Couto's post over 4 years

not sure if you've found a solution,
have a look at this :
http://stackoverflow.com/questions/8707226/jquery-data-does-not-work-but-attrdata-itemname-does

``
The .data() call is special - not only does it retrieve HTML5 data attributes it also attempts to evaluate/parse the attributes. So with an attribute like data-myjson='{"hello":"world"}' when retrieved via .data() will return an Object while retrieval via .attr() will return a string. See jsfiddle example.

Since .data() does extra processing jQuery stores the results of attribute evaluation in $.cache - after all, once a data attribute has been evaluated it would be wasteful to re-evaluate on every .data() call - especially since data variables can contain complex JSON strings.
``

try to use .attr() or .css() instead, give it a try, not too sure but i think .css() is better

Posts Followed

No Content

Following

    No Content

Followers

My Posts

No Content

My Comments

You commented on Bruno Couto's post over 4 years

not sure if you've found a solution,
have a look at this :
http://stackoverflow.com/questions/8707226/jquery-data-does-not-work-but-attrdata-itemname-does

``
The .data() call is special - not only does it retrieve HTML5 data attributes it also attempts to evaluate/parse the attributes. So with an attribute like data-myjson='{"hello":"world"}' when retrieved via .data() will return an Object while retrieval via .attr() will return a string. See jsfiddle example.

Since .data() does extra processing jQuery stores the results of attribute evaluation in $.cache - after all, once a data attribute has been evaluated it would be wasteful to re-evaluate on every .data() call - especially since data variables can contain complex JSON strings.
``

try to use .attr() or .css() instead, give it a try, not too sure but i think .css() is better

Posts Followed

No Content

Following

  • No Content

Followers

  • No Content