set the hash attribute for the HTML anchor element "a"
The <a> (HTMLLinkElement) element already has the DOM Level 0 hash property. It is used as window.location.hash to read or set the "... # anchor part at the end of the URL that the href element refers to.
Configuring a.hash , whether directly or through jQuery attr() wrapper, simply sets the binding name in the url. You could consciously say that you want to get the actual attribute by calling the DOM method a.setAttribute('hash', value) , except that this does not work in IE6 / 7 due to a long-standing error in which it mixes the attributes and properties.
This is one of the problems with adding custom non-standard attributes to elements; you never know when they will encounter an existing name. HTML5 will offer you to limit your user attributes to names starting with "data-", but in general, it's best to find another way to store data if you can.
bobince
source share