I have this code, but I’m not sure how to convert it to jquery because of the check variable which I am using to see if the stuff inside the if statement happened at least once. gph_img_list is the name tag for lots of radio buttons.
var check = false;
for (var i=0; i < gph_img_list.length; i++) {
if (gph_img_list[i].value == var_gph_img.innerHTML) {
gph_img_list[i].checked = true;
check = true;
break;
}
}
if (!check) {
var_gph_img.innerHTML = "";
}
Use the filter function…
Here is a fiddle where there is no checkbox checked because the text doesn’t match. (Change the ‘a’ in the div to x, y or z to see the difference)
Here is a fiddle where there is a checkbox checked because the text does match.