I’m currently working on a very simple calendar using Jquery.
Actually, We need a Weekly view for some events, with the possibility to change the week using Jquery (like on Google Calendar).
The easiest way I thought is wrapping each week into a <div>, and with Jquery moving along the different divs / weeks in a slider-like style.
Actually I need a way to number the single divs, and I was thinking to use a “virtual” attribute week-number, i.e.
<div week-number="3"> ... </div>
That’s ok when moving to next weeks, but to go to the previous one? Logically, I would get negative week numbers, providing the starting week is numbered “1”, that’s to say
<div week-number="-3"> ... </div>
I really don’t like so much this approach, so have you any idea about identifying the different divs / weeks?
EDIT : Thinking about it: what about using numbered classes? as example class="week-1",class="week-2", etc. ?
This is why data attributes exists: http://ejohn.org/blog/html-5-data-attributes.
And of course you can be with a valid XHTML: How can I use HTML5 Data Attributes in XHTML?.
About your edit, I emphasize even more the use of data attributes. What you suggested works, but is merely a workaround to fix something that already has a right solution.
Even you could include in your project Modernizr if you really believe may have problems with older browsers. Well, I never had these problems.