How to find all Input elements that have a specific value?

Viewed 21

How to find all Input elements that have a specific value, e.g. "ABC" ? Both the JavaScript and its jQuery equivalent do not return any elements.

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

$('input[value="ABC"]'); // .length is 0
1 Answers

If the inputs value was set by js or the user, you have to check the inputs' value property and I don't believe there is a way to do that with a css selector.
You'll have to use good ole js

var $abc = $('input').filter((i,v) => v.value === "ABC");
Related