I'm building dynamically with JavaScript a HTML page and setting an attribute with a text.
Sometimes the text is a simple string and sometimes I have a JSON Object that I use JSON.stringify() to save it as a string.
$("<a id=\"ftr\" myData=\"" + myString + "\" </a>").appendTo(myDiv);
And after that I extracting this attribute:
var temp = $(this).attr("myData"); // inside loop , $(this) refers to the correct link
When it's a simple text like this, everything works fine.
<a id="ftr" myData="text test"></a>
But when extracting JSON object I get as a result only : "[{"
<a id="ftr" myData="[{"text":"test1","link":"http:\\www.google.com"},{"text":"test2","url":"http:www.google.com"}]></a>
How can I extract the full object in JSON format?