title: How to get last option value between multiple selects in jQuery
body: <p>I am having a problem to getting last selected option value in multiple select boxes the problem is, I have 4 select boxes you can see in the below image. I want to get the last option value through jquery. </p>
  
  <p>I have tried this code but not getting the last exact value.</p>
  
  <pre><code>$('.option').find('option:selected').attr("name")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/w8r5m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w8r5m.png" alt="enter image description here"></a></p>
  
  <p>This is my form.</p>
  
  <pre><code>&lt;form method="post" id="form-id"&gt;
  &lt;div class="form-group"&gt;
      &lt;label&gt;Size&lt;/label&gt;
      &lt;select class="form-control option" name="size" required&gt;
          &lt;option value=""&gt;Choose option&lt;/option&gt;
          &lt;option&gt;8.2 * 11.6 in (A4)&lt;/option&gt;
          &lt;option&gt;11.7 x 16.5 in (A3)&lt;/option&gt;
          &lt;option&gt;16.5 x 23.4 in (A2)&lt;/option&gt;
          &lt;option&gt;23.4 x 33.1 in (A1)&lt;/option&gt;
          &lt;option&gt;33.1 x 46.8 in (A0)&lt;/option&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label&gt;Paper&lt;/label&gt;
      &lt;select class="form-control option" name="paper" required&gt;
          &lt;option value=""&gt;Choose option&lt;/option&gt;
          &lt;option&gt;A4&lt;/option&gt;
          &lt;option&gt;A3&lt;/option&gt;
          &lt;option&gt;A2&lt;/option&gt;
          &lt;option&gt;A1&lt;/option&gt;
          &lt;option&gt;A0&lt;/option&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label&gt;Appearance&lt;/label&gt;
      &lt;select class="form-control option" name="appearance" required&gt;
          &lt;option value=""&gt;Choose option&lt;/option&gt;
          &lt;option&gt;Black &amp; White&lt;/option&gt;
          &lt;option&gt;Color&lt;/option&gt;
          &lt;option&gt;Color Division&lt;/option&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
      &lt;label&gt;Large Format Binding&lt;/label&gt;
      &lt;select class="form-control option" name="binding" required&gt;
          &lt;option value=""&gt;Choose Option&lt;/option&gt;
          &lt;option&gt;No Binding&lt;/option&gt;
          &lt;option&gt;Blk Edge w/ Craft Paper (&lt;span class="amount"&gt;&amp;#36;3.50&lt;/span&gt;)&lt;/option&gt;
          &lt;option&gt;Blk Edge w/o Craft Paper (&lt;span class="amount"&gt;&amp;#36;2.00&lt;/span&gt;)&lt;/option&gt;
          &lt;option&gt;Full Bind and Label (&lt;span class="amount"&gt;&amp;#36;4.00&lt;/span&gt;)&lt;/option&gt;
          &lt;option&gt;Post Bind &amp;#8211; Drilled Holes w/ Screw Post (&lt;span class="amount"&gt;&amp;#36;5.00&lt;/span&gt;)&lt;/option&gt;
          &lt;option&gt;Post Bind w/ Black Edge (&lt;span class="amount"&gt;&amp;#36;6.00&lt;/span&gt;)&lt;/option&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  &lt;button type="submit" class="btn btn-success cart" style="display:none"&gt;&lt;i class="fas fa-shopping-cart"&gt;&lt;/i&gt; Add to Cart&lt;/button&gt;
  </code></pre>
  
  <p></p>
  
  <p>And this is my script</p>
  
  <pre><code>&lt;script&gt;
  $('.option').change(function () {
  
      var check = $(this).val();
  
      var name = $(this).attr("name");
  
      if($('[name=paper]').val() == '' || $('[name=size]').val() == '' || $('[name=appearance]').val() == '' || $('[name=binding]').val() == '')
      {
          if(name == 'size')
          {
              if(check == '')
              {
                  $('#size').html('&lt;font color=red&gt; Please select a size &lt;/font&gt;');
                  $('.cart').hide();
              }
              $('#size').html(check);
          }
          else if(name == 'paper')
          {
              if(check == '')
              {
                  $('#paper').html('&lt;font color=red&gt; Please select a paper &lt;/font&gt;');
                  $('.cart').hide();
              }
              $('#paper').html(check);
          }
          else if(name == 'appearance')
          {
              if(check == '')
              {
                  $('#appearance').html('&lt;font color=red&gt; Please select appearance &lt;/font&gt;');
                  $('.cart').hide();
              }
              $('#appearance').html(check);
          }
          else if(name == 'binding')
          {
              if(check == '')
              {
                  $('#binding').html('&lt;font color=red&gt; Please select a binding &lt;/font&gt;');
                  $('.cart').hide();
              }
              $('#binding').html(check);
          }
      }
      else
      {
          console.log($('.option').val());
          $('.cart').show();
          return false;
      }
  });
  
  &lt;/script&gt;
  </code></pre>