Get Data Attributes to Object

by bizamajig

HTML

<link rel="stylesheet" href="http://dl.dropbox.com/u/1722364/jsfiddle.css">
<p id="d" data-hello-world="world" data-pi="3.14" data-ars="http://www.arstechnica.com">The two men behind Super Meat Boy explain why  the game was released on sale, and why they asked the press to spread  the word of the price increase so no one "feels screwed." Welcome to the  world of a very unlikely indie hit.</p>

<h3>Data</h3>
<ul id="out">
    
</ul>

JavaScript

var data_attributes = $('#d').data();
console.log( data_attributes );
for (var i in data_attributes ){
    $('<li>', {
        text: i + ': ' + data_attributes[i]
    }).appendTo('#out');
}