Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select inputs that doesn't have value attribute with querySelector

Tags:

javascript

I'm using:

document.querySelectorAll('input[value=""]')

But it's not selecting inputs that doesn't have the attribute value.
How can I select all inputs that doesn't have a value '', and that doesn't have the attribute value?

I would like to do that without jQuery and without any additional function, would that be possible only using querySelectorAll?

like image 332
BernardoLima Avatar asked Jul 13 '26 05:07

BernardoLima


1 Answers

Try

document.querySelectorAll('input:not([value])')

This should return all the input that don't have the value attribute.

like image 158
jsfrocha Avatar answered Jul 14 '26 18:07

jsfrocha