document.querySelectorAll('input[type="text"]') 筛选 class 是 indexinput的
时间: 2024-03-11 19:47:33 浏览: 20
您可以使用如下代码来筛选class为indexinput且type为text的input元素:
```
document.querySelectorAll('input.indexinput[type="text"]')
```
这里使用了CSS选择器来选择元素,元素名为input,class为indexinput,type为text。其中`.`表示class选择器,`[]`代表属性选择器。
相关问题
寻找div类是 indexinput 下面 document.querySelectorAll('input[type="text"]')
您可以使用如下代码来查找div类是indexinput下面的所有input元素:
```javascript
document.querySelectorAll('div.indexinput input[type="text"]')
```
这里使用了CSS选择器来选择元素,首先选择class为indexinput的div元素,然后在该div元素内部选择type为text的input元素。其中空格表示后代选择器。
setTimeout(() => { document.querySelectorAll('.form-content .slt .el-input__prefix').forEach(el => { el.style.color = this.contents.inputIconColor el.style.lineHeight = this.contents.inputHeight }) document.querySelectorAll('.form-content .slt .el-input__suffix').forEach(el => { el.style.color = this.contents.inputIconColor el.style.lineHeight = this.contents.inputHeight }) document.querySelectorAll('.form-content .slt .el-input__icon').forEach(el => { el.style.lineHeight = this.contents.inputHeight }) }, 10 ) })
这段代码是在 10 毫秒后执行一个函数,用于修改表单中输入框的图标样式。具体来说,它首先遍历所有 class 为 `.form-content .slt .el-input__prefix` 的元素,设置它们的颜色和行高为 `this.contents.inputIconColor` 和 `this.contents.inputHeight`;然后遍历所有 class 为 `.form-content .slt .el-input__suffix` 的元素,设置它们的颜色和行高为 `this.contents.inputIconColor` 和 `this.contents.inputHeight`;最后遍历所有 class 为 `.form-content .slt .el-input__icon` 的元素,设置它们的行高为 `this.contents.inputHeight`。其中 `this.contents` 可能是一个对象,里面存放了一些表单相关的配置信息。这个函数的延迟执行是为了等待表单渲染完成后再修改样式,避免出现样式错乱的情况。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)