title: jQuery - Get selected value from json object
body: <p>What I am trying to do is that when an option is selected (for example #4) I get the date from the json object so it would render out: "Monday 26th December". I'm struggling to display this - does anyone know how I could do this please?</p>
  
  <p><a href="https://jsfiddle.net/9L53epre/3/" rel="nofollow noreferrer">https://jsfiddle.net/9L53epre/3/</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() {
    $('select').change(function() {
      var val = $(this).val();
      console.log(val);
    });
  
    var data = $('#delivery-date').data('delivery-date');
  
    console.log(data);
    // console.log(data.item[val]);
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;span id="delivery-date" data-delivery-date='{"1":"","2":"","3":"","4":"Monday 26th December","5":"","6":"","7":"Friday 23rd December","8":"","9":""}
  '&gt;&lt;/span&gt;
  
  &lt;select&gt;
    &lt;option value="1"&gt;option 1&lt;/option&gt;
    &lt;option value="2"&gt;option 2&lt;/option&gt;
    &lt;option value="3"&gt;option 4&lt;/option&gt;
    &lt;option value="4"&gt;option 4&lt;/option&gt;
  &lt;/select&gt;</code></pre>
  </div>
  </div>
  </p>