title: jquery .change() in a laravel loop
body: <p>I am trying to make js dynamic inside a laravel loop.</p>
  <p>My intention is that when selecting a product from the &quot;product&quot; select, load its value.</p>
  <p>Laravel view:</p>
  <pre class="lang-xml prettyprint-override"><code>@for ($i = 0; $i &lt;= sizeof($fibra[&quot;voz&quot;]) - 1; $i++)
    &lt;div class=&quot;form-group&quot;&gt;
      &lt;label for=&quot;wifi&quot;&gt;Wifi {{ $i + 1 }}&lt;/label&gt;
      &lt;select class=&quot;form-control wifi&quot; name=&quot;wifi&quot; data-repeat=&quot;{{ $i }}&quot; required&gt;
        &lt;option selected hidden disabled&gt;Elige un wifi...&lt;/option&gt;
        @foreach ($wifis_inversor as $wifi_inversor)
          &lt;option data-comission=&quot;{{ $wifi_inversor-&gt;commission }}&quot; value=&quot;{{ $wifi_inversor-&gt;name }}&quot;&gt;{{ $wifi_inversor-&gt;name }}&lt;/option&gt;
        @endforeach
      &lt;/select&gt;
    &lt;/div&gt;
  @endfor
  </code></pre>
  <p>My jquery code:</p>
  <pre class="lang-js prettyprint-override"><code>var comision = $('.comision_total');
  var comision_total = 0;
  var comision_total_wifi = 0;
      
  $('.wifi').change(function () {
      var idRepeat = $('.wifi').attr(&quot;data-repeat&quot;);
      var comision_wifi = $('.wifi[data-repeat=' + idRepeat + ']').find(':selected').data('comission');
      comision_anterior = comision_total_wifi;
      comision_total_wifi = comision_wifi;
      comision_total = comision_total + comision_total_wifi - comision_anterior;
      comision.val(comision_total);
  });
  </code></pre>
  <p>My intention is to add the &quot;commission&quot; dynamically whenever, in any of the selects, the product changes. But it only works for me for the first select. The second does not. How can I solve it?</p>