title: How can I get the values of data attributes in JavaScript code?
body: <p>I have next html:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;span data-typeId=&quot;123&quot; data-type=&quot;topic&quot; data-points=&quot;-1&quot; data-important=&quot;true&quot; id=&quot;the-span&quot;&gt;&lt;/span&gt;
  </code></pre>
  <p>Is it possible to get the attributes that beginning with <code>data-</code>, and use it in the <strong>JavaScript</strong> code like code below? For now I get <code>null</code> as result.</p>
  <pre class="lang-js prettyprint-override"><code>document.getElementById(&quot;the-span&quot;).addEventListener(&quot;click&quot;, function(){
      var json = JSON.stringify({
          id: parseInt(this.typeId),
          subject: this.datatype,
          points: parseInt(this.points),
          user: &quot;H. Pauwelyn&quot;
      });
  });
  </code></pre>