title: Trigger click based on changes in specific div classes - needs to loop
body: <p>In my function, when the user changes something inside the <code>.ap-create-story-panel-wrap</code> div, and then clicks outside that specific div, trigger a button click. </p>
  
  <p>As the selector for the container variable, I am using the data-panel attribute. This works for the first one, but I need it to work for all the other <code>.ap-create-story-panel-wrap</code> divs as well. </p>
  
  <p>I tried with a loop, with the data attribute as a selector, but nothing worked.</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>$('.ap-create-story-panel-wrap[data-panel="basicinfopanel"]').change(function() {
    $(document).mouseup(function(e) {
      var container = $('.ap-create-story-panel-wrap[data-panel="basicinfopanel"]');
  
      // if the target of the click isn't the container nor a descendant of the container
      if (!container.is(e.target) &amp;&amp; container.has(e.target).length === 0) {
        $(".btn-basicinfopanel").trigger("click");
      }
    });
  });</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;div class="ap-create-story-panel-wrap" data-panel="infopanel"&gt;
    &lt;input type="text"&gt;
  &lt;/div&gt;
  &lt;a class="btn-basicinfopanel" data-target="certificatepanel"&gt;Save/Next&lt;/a&gt;
  
  &lt;div class="ap-create-story-panel-wrap" data-panel="certifypanel"&gt;
    &lt;input type="text"&gt;
  &lt;/div&gt;
  &lt;a class="btn-certifypanel" data-target="certifypanel"&gt;Save/Next&lt;/a&gt;
  
  &lt;div class="ap-create-story-panel-wrap" data-panel="photopanel"&gt;
    &lt;input type="text"&gt;
  &lt;/div&gt;
  &lt;a class="btn-photopanel" data-target="photopanel"&gt;Save/Next&lt;/a&gt;</code></pre>
  </div>
  </div>
  </p>