jqSOCKET E2
A bit more complex and usefull jqSOCKET Plug
by dbjdbj
HTML
<script src="http://dbj.org/6/jqplug/jquery.moreSelectors.js"></script>
<script src="http://dbj.org/6/jqplug/jquery.metasocket.js"></script>
<button id="specimen">Specimen 1</button>
<button id="specimen2">Specimen 2</button>
<button id="specimen3">Specimen 3</button>
CSS
button { width: 100px; height: 30px; bottom:100px; }
JavaScript
/* Object to store things collected from dom elements */
var result = {};
/* Function called on each element in jQuery stack, to collect attributes or style properties */
function collector() {
var names = arguments,
id_ = function (el) {
return el.tagName + (el.id ? "#" + el.id : "");
},
set_ = function (obj) {
return obj || {};
},
for_each_name = function (callback) {
for (var j = 0, l = names.length; j < l; j++) callback(names[j], j);
};
/* the "plug" */
return function (P) {
var id = id_(this);
for_each_name(function (name, idx) {
if (undefined === P.nvo[name]) {
result[id][name] = "undefined";
} else {
result[id] = set_(result[id]);
result[id][name] = P.nvo[name].value;
}
});
return false;
}
};
$("button[~ bottom]")
.S(collector('bottom'));
var show_ = JSON.stringify(result);
alert(
show_.split("{").join("{\n").split("}").join("}\n")
);