June 18, 2013
Selecting more than one option
User2386255’s Question:
I have the following code working pretty well, but I want to be able to select more than one option if need be: http://jsfiddle.net/exlondoner/MKa3n/
Can anyone help?
JS:
$('.media-select-option').on('click', function() {
$('.media-select-option').removeClass('selected');
$(this).addClass('selected');
$('.m-overlay-close-btn').addClass('checked');
});
Try this:
$('.media-select-option').on('click', function () {
$(this).toggleClass('selected');
$('.m-overlay-close-btn').addClass('checked');
});
It is not working because there is no such element with class m-overlay-close-btn
$('.overlay-close-btn').addClass('checked');