jQuery の attr を見る

by ethertank

HTML

<div id="div1" style="backgroud-color:red" class="c1 c2" onclick="alert('hello');">aaa</div>

JavaScript

var echo = function(str){
    document.write(str + "<br />")
};

jQuery(function($){
    var $div = $("#div1");
    
    echo($div.attr("style"));
    echo($div.attr("class"));
    echo($div.attr("onclick"));
});