i trying to change the source of a set of images with JSON data that's been sent over from another page, the JSON data that looks like this:
var jsondata = {
"images": [
{"src": "images/bgset.jpg"},
{"src": "images/ar006.png"},
{"src": "images/br006.png"},
{"src": "images/cr006.png"},
{"src": "images/dr006.png"},
{"src": "images/er001.png"},
{"src": "images/tr004.png"},
{"src": "images/tr011.png"}
]}
And im trying to change the src values of set of images with the class of .imageset. im also tiring to work out a way to leave the first one in the JSON data {"src": "images/bgset.jpg"}. im lost not knowing how to get around this problem. im not even sure on how to get the values out of this data!
Update
thanks for the answers! With the answers i have currently created this:
var jsonStr = location.search.substring(1).split('=');
var obj = JSON.parse(unescape(jsonStr[1]));
var jsondata = JSON.parse(obj.jsondata);
var aa = jsondata.images.length;
var ab = jsondata.images.slice(1, aa); // this part removes the first src
var ac = $(".imageset");
// here is the confusion part i found this will go through the set
for( var i = 0; i < aa; i++ ) {
}
// and this will go through each class
ac.each( function() {
})
how do i join both this codes can put one image src per class?