I am trying to select inputs
that they contain a certain word in the id
I am doing it in the following way, but the id, apart from containing a word, contain the symbol ]
, so when searching with jquery, it gives the following error
function prueba() {
var value = "UNIT_PRICE" + "]";
var prueba = $("[id*="+value+"]").val();
console.log(prueba);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="Price[546][UNIT_PRICE]" type="text">
<button onclick="prueba()">Buscar</button>
Syntax error, unrecognized expression: [id*=UNIT_PRICE]]
If you can't remove the brackets, the solution would be something like this: