readAttribute :: Element

readAttribute(element, attribute) -> String | null Returns the value of element's attribute or null if attribute has not been specified.

This method serves two purposes. First it acts as a simple wrapper around getAttribute which isn't a "real" function in Safari and Internet Explorer (it doesn't have .apply or .call for instance). Secondly, it cleans up the horrible mess Internet Explorer makes when handling attributes.

Examples

<a id="tag" href="/tags/prototype" rel="tag" title="view related bookmarks." my_widget="some info.">Prototype</a>

$('tag').readAttribute('href');

// -> '/tags/prototype'

$('tag').readAttribute('title');

// -> 'view related bookmarks.'

$('tag').readAttribute('my_widget');

// -> 'some info.'

Prototype API 1.5.0 - prototypejs.org