0
4

1 回答 1

2

My question is, can I just use the <a> elements tag attribute

There is no tag attribute in HTML. So that will have all the problems of data-* but without the future support.

If you want to store arbitrary data in HTML 4/XHTML 1 then the best attribute to use is probably class.

The href attributes value is set to: javascript:void(0); because the actual URL triggers an AJAX event

Don't do that. Use a real (working) URI, and add a JavaScript event handler that prevents the default behaviour if it succeeds. If the URI contains the data you need for your JS to run, then all the better as you can extract it from the href attribute.

于 2012-10-03T06:38:18.443 回答