This question already has an answer here:
- jQuery attribute selector variable 3 answers
- jQuery selectors with variables 5 answers
In the function below, I'd like the idurl
be the word apple with a suffix. The suffix is number
containing a number. Example would be apple12
.
But in the function below, I have trouble concatenating the variable number
with the word apple.
function apple(number) {
if (something === "0") {
$('.onchange :checkbox[idurl="apple" + number]').prop('checked', false);
} else {
$('.onchange :checkbox[idurl="apple" + number]').prop('checked', true);
}
};
I tried using extra " or [] but it hasn't been very succesfull so far. The variable number
is not bein recognized as a variable and thus not concatenated with the word apple.