James & Ricardo,
Thank you both for the detailed responses, I appreciate it.
I didn't realize HTML 5 can be used NOW without having to wait for
browser quirks. In that case, it is absolutely the way to go. I
already have this working and it is great, very clean, the way it
should be IMO. If f
You can put data inside the class attribute (like ), it's perfectly valid. The class
attribute is not meant for presentation only according to the HTML/
XHTML specs. http://plugins.jquery.com/project/metadata
Or, use the HTML5 doctype (with valid mark-up
obviously) and the new data-xx attribute,
If you have to store several values, I recommend that you store the
data with Javascript separately, such as in arrays or JSON. The only
downside is that you're doing the loop twice in your server-side code
(one for the Javascript, one for the HTML table rows). But it's more
organized and easier t
Thanks James, I just found the data() method. I am not a fan of
squishing a bunch of data into a standard attribute, like id, and then
using some sort of regexp or a dirty string split on it to read it
back. In real life there are are arrays etc generated in the
onclick="", this is hard to read
I usually go with the element attribute method if all my content are
generated server-side. Either id, or if that's not available, I use
class.
blah
$(".mydiv").click(function() {
var id = this.id.split('_')[1]; // 12345
});
Otherwise if you want to generated it client-side and have a list
5 matches
Mail list logo