1 | var test = document.querySelectorAll('input[value][type="checkbox"]:not([value=""])'); |
以下是範例
.html
1
2
3
4
5<input type="checkbox" id="c2" name="c2" value="DE039230952"/>
<input type="checkbox" id="c2" name="c2" value=""/>
<input type="checkbox" id="c2" name="c2" />
<input type="text" id="c2" name="c2" value="DE039230952"/>
<input type="radio" id=.css
1
2
3
4input{
display:block;
margin:20px;
}.js
1
2
3
4
5var test = document.querySelectorAll('input[value][type="checkbox"]:not([value=""])');
for (var i = 0; i < test.length; i++) {
test[i].disabled = "disabled"
}