jquery - Do not select if the parent class is hidden -


with code below selecting checkboxes , radio buttons send them array.

var options = []; $('.option input[type="checkbox"]:checked, .option input[type=radio]:checked').each(function() {     options.push($(this).val()); }); var options_checked = options.join(','); 

there single radio buttons have parent class sass_syntax , of course selected. don't want select them if class sass_syntax hidden (display: none). how can this?

you can exclude them using .not() filter

var options = $('.option input[type="checkbox"]:checked, .option input[type=radio]:checked').not('.sass_syntax:hidden input').map(function() {   return $(this).val(); }).get(); var options_checked = options.join(','); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -