I need a string to be modified whenever any of checkboxes are checked/unchecked but only the first checkbox does the job when others throw me an exception error: " "#two-stars".is is not a function ". I've tried different conditions but it seems something is wrong at the very core of this code which I wasn't been able to find yet. Code:
$('#input:checkbox').change(function(){
starsQueries = '';
if( $('#two-stars').is(':checked') ){
starsQueries += '&stars=401';
console.log('checked!');
}
if( $('#three-stars').is(':checked') ){
if( ('#two-stars').is(':checked') ){
starsQueries += ',402';
} else {
starsQueries += '&stars=402';
}
}
if( $('#four-stars').is(':checked') ){
if( ('#three-stars').is(':checked') || ('#two-stars').is(':checked') ){
starsQueries += ',403';
} else {
starsQueries += '&stars=403';
}
}
if( $('#five-stars').is(':checked') ){
if( ('#four-stars').is(':checked') || ('#three-stars').is(':checked') || ('#two-stars').is(':checked') ){
starsQueries += ',404';
} else {
starsQueries += '&stars=404';
}
}
});
On JSfiddle: https://jsfiddle.net/4mLcz6mt/1/
Aucun commentaire:
Enregistrer un commentaire