I have a div that returns an array string:
<div class="overview"><%=getCurrentAttribute('item','item_specs_json','""')%></div>
An array string that looks like this:
[{"k":"type","v":"blue"},{"k":"size","v":"large"}]
I am making a bulleted list from these and there are 25 instances of div.overview per page.
This works but only repeats the first item values for every div. I can't get this to loop each.
Is it possible to do this with what I have?
$(function () {
var specs = $.parseJSON($(".overview").html());
$("div.overview").html('<div class="bullet_spec"></div>');
$.each(specs, function () {
$('div.overview div').append('<ul class="specs"><li class="label">' + this.k + ' : ' + this.v + '</li></ul>');
});
});
I've tried:
$('.overview').each(function () {
and this breaks the script.
Also FYI, when the script breaks the unique values appear on items correctly in the full array string format.