title: Jquery select and replace with check mark only one table row's radio input at a time
body: <p>Hi i just trying to figure out laravel foreach loop on a table. I want to when radio input selected changed with a check mark and background color green. If select other radio input, old input unchecked and selected check mark. It will continue like this for each radio input.</p>
  <pre><code>&lt;table class=&quot;table&quot;&gt;
    @foreach ($iterable as $key)
    &lt;tr&gt;
      &lt;td&gt;$key['name']&lt;/td&gt;
      &lt;td&gt;
        &lt;input id=&quot;id$key['id']&quot; type=&quot;radio&quot; name=&quot;inputs&quot; value=&quot;val$key['id']&quot;&gt;
        &lt;label for=&quot;id$key['id']&quot;&gt;Select&lt;/label&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    @endforeach
  &lt;/table&gt;
  </code></pre>
  <p>I changed radio buttons views with like a buttons.</p>
  <pre><code>.table input[type=&quot;radio&quot;] {
      /* display: block; */
      /* position: absolute; */
      opacity: 0.01;
      z-index: 100;
    }
  
    .dable label {
      padding: 5px;
      border: 1px solid #CCC;
      cursor: pointer;
      z-index: 90;
    }
  
    .table label:hover {
      background: #DDD;
    }
  </code></pre>
  <p>I have it below but something missing. So how can do it with jquery?</p>
  <pre><code>    $(function(){
    $(&quot;.table input[type='radio']&quot;).on(&quot;change&quot;, function(){
      var isChecked = $(this).is(':checked').length;
      var label = $(&quot;label[for='&quot; + $(this).attr('id') + &quot;']&quot;);
      $(this).each(function(index) {
        if(isChecked &lt; 1){
          $(label).html(&quot;&lt;span&gt;Select&lt;/span&gt;&quot;).css('background', 'white');
        }else{
          $(label).html(&quot;&lt;i class='glyphicon glyphicon-ok'&gt;&lt;/i&gt;&quot;).css('background', 'green');
        }
      });
    });
  });
  </code></pre>