How to select all flags with class "xxx"?

Welcome,

Is it possible to select all checkboxes / uncheck all checkboxes that have class "xxx"?

I cannot use "name" and "identifier" because they are generated dynamically through PHP, and I do not know their name.

So, can I add a class “xxx” for them that I can’t control?

Is it possible to?

Or if this is not possible. Maybye can I select all / unselect, what's inside the table with the identifier "selectall"?

Hi

+3
source share
3 answers

Here's how you can work with jquery : attr

$('input.xxx').attr('checked', 'checked');

xxx . , :

$('input.xxx').attr('checked', false);

id selectall :

$('table#selectall :checkbox').attr('checked', 'checked');

, :

$('table#selectall :checkbox').attr('checked', false);

:

$('table#selectall :checkbox').removeAttr('checked');
+5

"xxx":

$('.xxx:checkbox').attr('checked','checked');

.removeAttr('checked'), .

"selectall":

$('#selectall :checkbox').attr('checked','checked');
+2

" ", - :

$("#selectAll").change(function() {
  $(".xxx:checkbox").attr('checked', this.checked);
});

, , .xxx , , , "/ " .

0

Source: https://habr.com/ru/post/1749803/


All Articles