【发布时间】:2018-06-11 23:01:00
【问题描述】:
我尝试从以下位置获取数组的长度:
document.querySelectorAll('select,input,textarea');
alert(Object.keys(arr).length);//19
在该数组中,我必须排除 4 个元素,即 2 个 input type="hidden",以及 2 个带有特定 id's 的元素,所以我尝试使用 :not selector:
document.querySelectorAll('select,input,textarea,input:not[type="hidden",input:not[id="input_up_img_perfil"],input:not[id="sub_img_perfil"],');
alert(Object.keys(arr).length);//19
该查询的正确语法是什么?
【问题讨论】:
-
input:not('[type=hidden]'),您缺少否定运算符(:not())的括号,以及应该出现在第一个"hidden"之后的结束]字符。跨度> -
欢迎否定,如果可能,请尝试任何提示以使该问题变得更好!