There is an empty array ( var arr = []; ).
There are many checkboxes with the same class (you can cycle through the loop).
Question: how to make that if checkbox is active, then it is added to the array; if not, it is removed from the array. It is important to arr.length === количество активных checkbox'ов that arr.length === количество активных checkbox'ов . Events occur when you click on checkboxes.
Here is the code that keeps track of the change. But there is a slightly different functionality.
$( 'input.sl-chb' ).on( 'click', function() { $( '#cityList' ).html( $('input:checked' ).val() ); if(TextCity.innerHTML == 'Был выбран undefined'){ TextCity.innerHTML = 'Выберите город'; } }); Only one is displayed here. I need an array in order to make the conditions, they say if the length of the array is more than two, then .html('Выбрано городов : ' + arr.length;)