Element
- absolutize
- addClassName
- addMethods
- adjacent
- ancestors
- childElements
- classNames
- cleanWhitespace
- clonePosition
- cumulativeOffset
- cumulativeScrollOffset
- descendantOf
- descendants
- down
- empty
- extend
- fire
- firstDescendant
- getDimensions
- getElementsByClassName
- getElementsBySelector
- getHeight
- getOffsetParent
- getStyle
- getWidth
- hasClassName
- hide
- identify
- immediateDescendants
- insert
- inspect
- makeClipping
- makePositioned
- match
- next
- nextSiblings
- observe
- positionedOffset
- previous
- previousSiblings
- readAttribute
- recursivelyCollect
- relativize
- remove
- removeClassName
- replace
- scrollTo
- select
- setOpacity
- setStyle
- show
- siblings
- stopObserving
- toggle
- toggleClassName
- undoClipping
- undoPositioned
- up
- update
- viewportOffset
- visible
- wrap
- writeAttribute
readAttribute
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.'