Help to realize the idea, the second day I fight. You need to implement a drop-down list from the checkbox and when selected, the value should be displayed in the input, and when removed, deleted.
I implemented it like this, it seems to work, but if you put several inputs, then as a result, if you have a wedge on one, all the lists fall out, and if you drop it, then pretend the number of check values for all input values
<div class="col-3" id="col1"> <div class="headVolumeGroup" id="headVolumeGroup1"> <input class="effect-1" data-parameter="1" data-id="volumeGroupsStringReturnException1" type="text" autocomplete="off" id="volumeGroupsStringReturnException1" /> <span class="focus-border"></span> <p class="multiSel" id="multiSel1" hidden></p> </div> <div class="listVolumeGroup" id="listVolumeGroup1"> <div class="mutliSelect" id="mutliSelect1"> <ul> <li> <input type="checkbox" value="120" />120</li> <li> <input type="checkbox" value="138" />138</li> <li> <input type="checkbox" value="150" />150</li> </ul> </div> </div> </div> <div class="col-3" id="col2"> <div class="headVolumeGroup" id="headVolumeGroup2"> <input class="effect-1" data-parameter="2" data-id="volumeGroupsStringReturnException2" type="text" autocomplete="off" id="volumeGroupsStringReturnException2" /> <span class="focus-border"></span> <p class="multiSel" id="multiSel2" hidden></p> </div> <div class="listVolumeGroup" id="listVolumeGroup2"> <div class="mutliSelect" id="mutliSelect2"> <ul> <li> <input type="checkbox" value="120" />120</li> <li> <input type="checkbox" value="138" />138</li> <li> <input type="checkbox" value="150" />150</li> </ul> </div> </div> </div> and JS himself
$(document).ready(function(){ $(".col-3 .headVolumeGroup input").on('click', function() { $(".col-3 .listVolumeGroup ul").slideToggle('fast'); }); $(document).bind("click", function(e) { var $clicked = $(e.target); if (!$clicked.parents().hasClass("col-3")) $(".col-3 .listVolumeGroup ul").hide(); }); $('.mutliSelect input[type="checkbox"]').on("click", function() { var title = $(this) .closest(".mutliSelect") .find('input[type="checkbox"]') .val(), title = $(this).val() + ","; if ($(this).is(":checked")) { var html = '<span title="' + title + '">' + title + "</span>"; $(".multiSel").append(html); var val = $(".multiSel").text(); $(".col-3 .headVolumeGroup input").val(val); } else { $('span[title="' + title + '"]').remove(); var val = $(".multiSel").text(); $(".col-3 .headVolumeGroup input").val(val); } }); }); I tried to attribute attributes with the necessary id and a certain num, then to dazzle it up, so that everyone would take their own input. But in the end, the variables could not throw values.
Like this
$(document).ready(function(){ var element; var id; $(".col-3 .headVolumeGroup input").on('click', function() { id = this.getAttribute("data-parameter"); element = this.getAttribute("data-id"); $("#col" + id + " #listVolumeGroup" + id + " ul").slideToggle("fast"); }); $(document).bind("click", function(e) { var $clicked = $(e.target); if (!$clicked.parents().hasClass("col-3")) $("#col" + id + " #listVolumeGroup" + id + " ul").hide(); }); $('#mutliSelect' + id + ' input[type="checkbox"]').on("click", function() { var title = $(this) .closest("#mutliSelect" + id) .find('input[type="checkbox"]') .val(), title = $(this).val() + ","; if ($(this).is(":checked")) { var html = '<span title="' + title + '">' + title + "</span>"; $("#multiSel" + id).append(html); var val = $("#multiSel" + id).text(); $("#col" + id + " #headVolumeGroup" + id + " #" + element).val(val); } else { $('span[title="' + title + '"]').remove(); var val = $("#multiSel" + id).text(); console.log(element); $("#col" + id + " #headVolumeGroup" + id + " #" + element).val(val); } }); }); Naturally did not work as needed.
Help pliz yourself while in the initial stages of learning jQuery. On js I could do it, but I would like to understand how it is on jQuery.