js方法(3)
}, val:function (value) {
if (value === undefined) {
var values = [];
for (var i = 0; this.length >= 1, i < this.length; i++) {
if (this[i].value !== undefined) {
values.push(this[i].value);
}
}
return values.join(",");
} else {
for (var i = 0; i < this.length; i++) {
if (this[i].value !== undefined) {
this[i].value = value;
}
}
}
}, text:function (text) {
if (text === undefined) {
var texts = [];
for (var i = 0; this.length >= 1, i < this.length; i++) {
function getNodes(n) {
var nodeList = n.childNodes;
for (var j = 0; j < nodeList.length; j++) {
if (nodeList[j].nodeType === 3) {
texts.push(nodeList[j].nodeValue);
} else {
if (nodeList[j].nodeType === 1) {
getNodes(nodeList[j]);
}
}
}
}
getNodes(this[i]);
}
return texts.join("");
} else {
this.each(this, function (text) {
this.innerHTML = text;
}, text);
return this;