Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS HTML5 data attributes and Jquery problem Re: HTML5 data attributes and Jquery problem

#128084
CrocoDillon
Participant

$(‘[data-day=’+d.getDate()+’] > h2′).addClass(‘highlight’);

The [`.data()`](http://api.jquery.com/data/#data2) function only returns the data attribute for the first element of a set, so your variables are pretty much useless. It’s not that inefficient to store values though. It’s a trade-off of memory vs cpu, most of the time memory is abundant.