title: get the updated value of data attr jquery
body: <p><div class="snippet" data-lang="js" data-hide="true">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('select').change(function() {
    var value = $('option:selected', this).val()
  
    //var sum = parseInt(value);
    if (value &lt; '1') {
      $("#noradiobutton").attr('data-finalvalue', 0);
      $("#input:text").val(0);
  
    } else {
      console.log(value)
      $('#yesradiobutton').attr('data-finalvalue', value);
      $('#input:text').val(value);
    }
  
  
    $('input:text').val(value)
  
  }).change();
  
  $("input:radio[name=yesnoradiobuttongroup]").change(function() {
    var finalvalue;
    if ($("#yesradiobutton").is(':checked')) {
      finalvalue = $(this).data('finalvalue');
      console.log(finalvalue)
      $('input:text').val(finalvalue);
    }
    if ($("#noradiobutton").is(':checked')) {
      finalvalue = $(this).data('finalvalue');
      console.log(finalvalue)
      $('input:text').val(finalvalue);
    }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;select&gt;
    &lt;option&gt;&lt;/option&gt;
    &lt;option value='1'&gt;1&lt;/option&gt;
    &lt;option value='2'&gt;2&lt;/option&gt;
    &lt;option value='3'&gt;3&lt;/option&gt;
    &lt;option value='4'&gt;4&lt;/option&gt;
    &lt;option value='5'&gt;5&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;input type='text'&gt;
  &lt;span&gt;&lt;input type="radio" id="yesradiobutton" name="yesnoradiobuttongroup" value="0" class="InputBoxDe" checked/&gt;&lt;label for="yesradiobutton"&gt;Yes&lt;/label&gt;&lt;/span&gt;
  &lt;span&gt;&lt;input type="radio" id="noradiobutton" name="yesnoradiobuttongroup" value="1" class="InputBoxDe" /&gt;&lt;label for="noradiobutton"&gt;No&lt;/label&gt;&lt;/span&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have here select input and radio button. When select is change the value is stored in input and also in radio button as <code>data attr</code>. I am getting the first value of <code>data attr</code> but I can't get the updated value to show up in input text. But when checking in the dev tools the value in <code>data attr</code> is changing.</p>
  
  <p>Question: How to get the latest the value of <code>data attr</code></p>
  
  <p>Scenario: After load select <code>1</code> in select option. <code>1</code> will be displayed in input and stores in Yes radio button as <code>data attr</code>. If you click <code>No</code> data in input will be <code>0</code> clicking <code>Yes</code> will turn it to 1 which is the <code>data attr</code>. Selecting <code>2</code> in select will dispay <code>2</code> in input and also in <code>data attr</code> of radio button Yes. Clicking No will again put <code>0</code> in input and clicking Yes will display <code>1</code> instead of <code>2</code> which is the current value of <code>data attr</code>.</p>
  
  <p>Requirement: after clicking yes input should display 2 which is the <code>data attr</code> of yes button</p>
  
  <p><strong><em><a href="https://jsfiddle.net/2hx1xvwg/" rel="nofollow">FIDDLE DEMO</a></em></strong></p>