title: How to get data from a special attribute in datalist using javascript?
body: <p>I want to get the data inside &quot;opt_id&quot;.
  And the same code works when i use <code>selelct</code> tag insted of <code>datalist</code>.</p>
  <p><strong>This is how my code looks like:</strong></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>var get_data = document.getElementById("select_opt");
  var dataIndex = get_data.options[get_data.selectedIndex].getAttribute("opt_id");</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input id="optio_lists" list="options" placeholder="Search..."&gt;
  &lt;datalist id="select_opt"&gt;
  &lt;option opt_id="0"  label="Cricket"&gt;Cricket&lt;/option&gt;
  &lt;option opt_id="1"  label="Football"&gt;Football&lt;/option&gt;
  &lt;option opt_id="2"  label="Tennis"&gt;Tennis&lt;/option&gt;
  &lt;option opt_id="3"  label="Basketball"&gt;AKITA&lt;/option&gt;
  &lt;/datalist&gt;</code></pre>
  </div>
  </div>
  </p>