prototype の readAttribute

by ethertank

HTML

<a
 id="tag"
 href="http://google.co.jp"
 rel="relValue"
 title="titleValue"
 onclick="alert('hello')",
 my_widget="some info."

>Prototype</a>

<textarea id="ta" readonly="readonly">aaaaaa</textarea>

JavaScript

var echoArray = function(ary){
    for(var i = 0; i < ary.length; i++){
        document.write(ary[i] + "<br />");
    }
};

echoArray([
    $('tag').readAttribute('href'),
    $('tag').readAttribute('title'),
    $('tag').readAttribute('my_widget'),
    $('tag').readAttribute('onclick'),
    $('ta').readAttribute('readonly')
]);