ну отсечь лишние наверное
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<input name="test" id="myid" size=50>
<input name="test2" id="myid2" size=100>
<script>
$(function () {
$(':text').each(function () {
var at = this.attributes;
var arr = [];
for (var key in at) {
if (at[key].nodeName != undefined) {
arr.push(at[key].name + ' = ' + at[key].value);
}
}
alert(arr)
});
});
</script>
UPD: хотя и так не плохо
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<input name="test" id="myid" size=50>
<input name="test2" id="myid2" size=100>
<script>
$(function () {
$(':text').each(function () {
var at = this.attributes;
var len = at.length;
var arr = [];
for (var i = 0; i < len; i++) {
arr.push(at[i].name + ' = ' + at[i].value);
}
alert(arr);
});
});
</script>
А так ещё лучше
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<input name="test" id="myid" size=50>
<input name="test2" id="myid2" size=100>
<script>
$(function () {
$(':text').each(function () {
var arr = [];
$(this.attributes).each(function () {
arr.push(this.name + ' = ' + this.value);
});
alert(arr);
});
});
</script>