title: What's the difference between jquery's data(key,val) and attr(data-key,data-val)
body: <p>If you try to change a data attribute value with <code>data()</code> method you don't get the same result as <code>attr(data-key, data-value)</code> method.  </p>
  
  <p>For example, I'm using <code>data-hovered=true</code> to store some state for the element. If you have some css styling for the <code>element[data-hovered=true]</code> selector, using <code>data()</code> method to assing the value <code>true</code> to <code>data-hovered</code> won't have effect. Only using <code>attr()</code> this would have effect.  </p>
  
  <p>So what's the difference between these two methods?</p>