title: jQuery checkbox gallery select
body: <p>How can I create a JQuery function for the following?</p>
  <p>When I checked the images I want to click the button and copy that images to another  for working with that selected images.</p>
  <p>Here is the sample I made, but it's not working good:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>            $(document).ready(function () {
                  $('input[name="obrazky"]').click(function () {
                      getSelectedCheckBoxes('obrazky');
                  });
  
                  var getSelectedCheckBoxes = function () {
                      var result = $('input[name="obrazky"]:checked');
                      if (result.length &gt; 0) {
                          var resultString = result.length + " checkbox checked&lt;br/&gt;";
                          result.each(function () {
                              var selectedValue = $(this).val();
                              resultString += selectedValue + " - "
                                  + $('label[class="obrazek' + selectedValue + '"]').html() + "&lt;br&gt;";
                          });
                          $('#showselected').html(resultString);
                      }
                      else {
                          $('#showselectedk').html("No checkbox checked");
                      }
                  };
              });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;label class="obrazek1"&gt;&lt;input type="checkbox" name="obrazky" class="filled-in" value="1"&gt;&lt;span&gt;&lt;/span&gt;&lt;img alt="" height="100" width="100" src="https://tvorbawebu.net/eshopserver/uploads/Pentair-Led-Pool-Lights.jpg"&gt;&lt;/label&gt;   
         &lt;label class="obrazek2"&gt;&lt;input type="checkbox" name="obrazky" class="filled-in" value="2"&gt;&lt;span&gt;&lt;/span&gt;&lt;img alt="" height="100" width="100" src="https://tvorbawebu.net/eshopserver/uploads/f823888da14805caf9a229986595f06c.jpg"&gt;&lt;/label&gt;
         &lt;label class="obrazek3"&gt;&lt;input type="checkbox" name="obrazky" class="filled-in" value="3"&gt;&lt;span&gt;&lt;/span&gt;&lt;img alt="" height="100" width="100" src="https://tvorbawebu.net/eshopserver/uploads/Downunda-perimeter-overflow-pool-raised-spa-fire-bowls_490.jpg"&gt;&lt;/label&gt;
         
  
          &lt;div id="showselected"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I wanna make like Wordpress files library, where you can choice your file and put in the main post thumbnail.</p>
  <p>Thank you for help.</p>