title: How to use HTML data attributes to return object data?
body: <p>I'm currently using HTML data attributes to display basic information when an element is clicked using <code>$(this)</code>. For example, I have the following HTML snippet:</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>$('.element').on('click', function(e) {
    e.stopPropagation();
    $('#info').slideDown();
  
    var title = $(this).data('title');
    var desc = $(this).data('desc');
    var icon = $(this).data('icon');
  
    var info = $('#info');
  
    info.html('&lt;div class="sub-info"&gt;&lt;h1&gt;' + title + '&lt;/h1&gt;&lt;h1 class="icon"&gt;' + icon + '&lt;/h1&gt;&lt;/div&gt;&lt;div class="side-info"&gt;&lt;p&gt;' + desc + '&lt;/p&gt;&lt;/div&gt;');
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="element" data-title="title" data-desc="desc" data-icon="H"&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>It's working as intended but I need more information and keeping it in objects would be a lot cleaner I think. Could anyone point me in the right direction?</p>