var walk_the_DOM = function walk(node, func){ func(node); node = node.firstChild; while (node) { walk(node,func); node = node.nextSibling; } }; var getElementsByAttribute = function (att, value) { var results = []; walk_the_DOM(document.body,function (node) { var actual = node.nodeType === 1 && node.getAttribute(att); if (typeof actual === "string" && (actual === value || typeof value !== "string")) { results.push(node); } }); return results; };主要是if (typeof actual === "string" && (actual === value || typeof value !== "string"))这一句
添加回答
举报
0/150
提交
取消