title: Max value of input from selected data-attribute
body: <p>i'm setting max value of an input based on the selection.</p>
  
  <p>if any of the option is selected i want its <code>data-max</code> attribute, to be set as max in the input field.</p>
  
  <p><strong>The select options</strong></p>
  
  <pre><code>&lt;select size="1" name="options" class="select"&gt;
    &lt;option value="30" data-max="40"&gt;30&lt;/option&gt;
    &lt;option value="31" data-max="22"&gt;31&lt;/option&gt;
    &lt;option value="32" data-max="4"&gt;32&lt;/option&gt;
    &lt;option value="33" data-max="400"&gt;33&lt;/option&gt;
    &lt;option value="34" data-max="36"&gt;34&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p><strong>this is the input where max value will be set:</strong></p>
  
  <pre><code>&lt;input type="number" class="qty" name="qty" value="1" min="1" max="100" /&gt;
  </code></pre>
  
  <p><strong>Tried this, but didn't worked</strong></p>
  
  <pre><code>$('select').change(function () {
      $('input[type=number]').attr('max', $(this).data('max'));
  });
  </code></pre>
  
  <p><strong><a href="https://jsfiddle.net/2kzdaLa1/4/" rel="nofollow">demo fiddle</a></strong></p>