Hello! There are two checkboxes, say, android and ios plus two multi-selections below - let's call them android-select and ios-select (so as not to bother with connecting the plug-in, in the example there will be just two inputs). Checkboxes are both initially selected.
The conditions are as follows:
- if both checkboxes are selected, both inputs are active;
- if no checkbox is selected, both inputs are active;
- if
androidselected,ios-selectbecomes inactive,android-selectis respectively active; - if
iosselected,android-selectis inactive,ios-selectis active.
I wrote a script, but I could not reflect the whole script in it (when both checkboxes are selected, the input paths are inactive) and in general I understand that it is curved / oblique and that should not be done. Please show a more correct and concise version ...
$(document).ready(function() { if ($('#android').is(':checked')) { $('#ios-select').addClass('inactive'); } else { $('#ios-select').removeClass('inactive'); } }); $('#android').on('change', function() { if(this.checked) { $('#ios-select').addClass('inactive'); } else { $('#ios-select').removeClass('inactive'); } }); $(document).ready(function() { if ($('#ios').is(':checked')) { $('#android-select').addClass('inactive'); } else { $('#android-select').removeClass('inactive'); } }); $('#ios').on('change', function() { if(this.checked) { $('#android-select').addClass('inactive'); } else { $('#android-select').removeClass('inactive'); } }); .checkbox-block { margin-bottom: 20px; } .multiselect-block > div { margin-bottom: 5px; } .multiselect-block input.inactive { opacity: .5; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="checkbox-block"> <input id="android" type="checkbox" checked> <label for="android">Android</label> <input id="ios" type="checkbox" checked> <label for="ios">iOS</label> </div> <div class="multiselect-block"> <div> <input id="android-select" type="text" placeholder="android-select" > </div> <div> <input id="ios-select" type="text" placeholder="ios-select"> </div> </div>