I have this piece of code to replace current text inside an array of html divs with values coming from a JSON file:
$.each($('.something'), function(){
if($(this).text()=="1"){
$(this).html(jsondata.CameraTypeLabel1);
}else if($(this).text()=="2"){
$(this).html(jsondata.CameraTypeLabel2);
}
});
I'd like to make it "dynamic": if I'd have 100 values, I don't want to copy/paste it 100 times.
Maybe it would be better creating an array "CameraTypeLabel" in the JSON string ?
EDIT: Fixed the selector, it was a typo.
Thanks!