I'm having several elements on my page with the same data attribute, although different values. The elements are formatted like so:
<input type="radio" data-toggle='["one","two","three"]'/>
Now, I want to get the data from all those elements, and I thought I could just do:
var data = $('[data-toggle]').data("toggle");
But this only outputs the data from the first element, all other elements with that data-attribute is ignored.
I'm guessing this has to do with it beeing arrays/JSON formatted, but I'm not clear about why this is the case, and how I should go about retrieving all my values.
How can I get all data from all those data attributes?
Here is a fiddle illustrating my problem: http://jsfiddle.net/6u67o9oo/