title: Why does .data() work on a set collection of elements, but not on a single element?
body: <p>I have a list of divs on my webpage, all with the data attribute <code>data-duration</code>.</p>
  
  <p>When I run the <code>.data("duration")</code> on all my divs, I get the <code>data-duration</code> of the first div. When I run it on a single element I get an error.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>$(".reservation").data("duration")
  &gt;&gt; 170
  $(".reservation")[0].data("duration")
  &gt;&gt; Uncaught TypeError: undefined is not a function
  </code></pre>
  
  <p>This code fails as well:</p>
  
  <pre><code>$(".reservation").each(function(index, elem) {
    return console.log(elem.data("duration"));
  });
  </code></pre>
  
  <p>I get a similar error with <code>.attr("data-duration")</code> on single elements.</p>
  
  <p>Why can't I get the data attribute of a single element?</p>