In check box list generated by Php foreach, i try to limit how many check box i can check and unchecked the last clicked.
var limit = 1;
var chkArrayCheckBoxOne = [];
$('input.catV').on('change', function(evt) {
chkArrayCheckBoxOne.push($(this).val());
if($(this).siblings(':checked').length >= limit) {
var TagO = chkArrayCheckBoxOne[0];
console.log(TagO);
$('input[value='+TagO+']').prop('checked', false);
chkArrayCheckBoxOne[0] = $(this).val();
}
});
This work fine if the value have no space. If the value is "Jhon" my limit work but if the value is "Jhon Doe" i get :
Syntax error, unrecognized expression: input[value=Jhon Doe]
Somebody have an idee ?