<script>
function attr(el, name, val) {
function trans(el, c) {
c = elcharAt(0);
c = cmatch(/^[#\\$]/) c : "";
return typeof el === "object" &&
ObjectprototypetoStringcall(el)match(/\[object HTMLElement\]/) el
: typeof el === "string" &&
(el = (document[
["getElementById", "getElementsByClassName", "getElementsByName", "getElementsByTagName"]
[{"#": 0, "": 1, "$": 2, "": 3}[c]]])(elsubstring(c 1 : 0)), c (el=[el]) : ellength) el : null;
}
el = trans(el);
if (el && typeof name === "string") {
if (argumentslength >= 3) {
if (ellength) {
var l = ellength;
while (l--) {
attr(el[l], name, val);
}
return;
}
if (elsetAttribute) {
elsetAttribute(name, val);
} else {
el[name] = val;
}
} else {
el = ellength && el[0] || el;
if (elgetAttribute) {
return elgetAttribute(name);
}
return el[name];
}
}
}
style("div","background-color","red");
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)