I have a multiple divs returning an array like this:
[{"k":"Model","v":"box"},{"k":"Color","v":"blue"},{"k":"Size","v":"med"},{"k":"Type","v":"good"}]
Sometimes, non-array items come back and I want to ignore those.
Could be blank spaces or random un-ordered blank lists.
So I only want to process only the arrays that come back leave the rest blank.
How could I check if it is array and ignore the rest?
jQuery('.overview').each(function () {
var $overview = jQuery(this),
specs = jQuery.parseJSON($overview.html());
if ( !! specs) {
$overview.html('<div class="bullet_spec"></div>');
jQuery.each(specs, function () {
$overview.children('div').append('<ul class="specs"><li class="label">' + this.k + ' : ' + this.v + '</li></ul>');
});
} else { // leave blank?? not sure what to do here
}
});
Here is my fiddle: http://jsfiddle.net/veGPN/
Thanks