Home > front end >  How to find all Input elements that have a specific value?
How to find all Input elements that have a specific value?

Time:07-23

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

CodePudding user response:

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