缩短了函数 querySelector 和 querySelectorAll
function get(s){
return document.querySelector(s);
}
function getAll(s){
return document.querySelectorAll(s);
}
NodeList.prototype.get=function(s){
return this.querySelector(s)
}
NodeList.prototype.getAll=function(s){
return this.querySelectorAll(s)
}
申请:
el=getAll("#dbdata tr")[r].getAll("td")[c].get(".cell")
控制台说.getAll is not a function
解决方案?
您已经在 NodeList 原型中编写了一个函数,并且您访问的不是元素列表,而是特定元素。
尝试在 Node 对象的原型中编写函数