If I have:
<a id="anchor" href="some link" rel="{ key1: 'value', key2 : 'value'}">text</a>
How do retrieve the values in the 'rel' attribute so i can refer to them using dot notation?
eg.
$('#anchor').attr('rel').key1
If I have:
<a id="anchor" href="some link" rel="{ key1: 'value', key2 : 'value'}">text</a>
How do retrieve the values in the 'rel' attribute so i can refer to them using dot notation?
eg.
$('#anchor').attr('rel').key1
Here you are giving rel
the value of a stringified JSON
object. You would need a JSON library and call
JSON.parse($('#anchor').attr('rel')).key1
You need a JSON deserializer or a jQuery JSON Plugin to convert the string into a JavaScript object (please don't just eval it).
var obj = JSON.parse($('#anchor').attr('rel'));
Directly attaching that object to your link with jQuery data might be an option, too.