Check input with 2 selectors

0

I need your help. I have the following code:

 $("input[numero='"+$("#jugada").val()+"']").each(function() {
    var monto = $(this).attr("monto");
    jugado = parseInt(jugado) + parseInt(monto);
  }) 

I want to know how to do so in:

$("input[numero='"+$("#jugada").val()+"']").each

I can do the check for 2 attributes, the attribute number and another attribute at the same time.

Thank you very much for your help!

    
asked by Carlos Maldonado 02.11.2018 в 14:42
source

2 answers

2

You can make a selector for attributes you like, for example:

input[atributo1='valor'][atributo2='valor']

A functional example:

$("input[numero='1'][monto='3000']").each(function() {
  var monto = $(this).attr("monto");
  console.log(monto);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input numero="1" monto="1000" type="text">
<input numero="2" monto="2000" type="text">
<input numero="1" monto="3000" type="text">
    
answered by 02.11.2018 в 14:50
1

If you look at the jQuery documentation, you'll see that in the Multiple-Attribute Selector section (selector with multiple attributes) the syntax is concatenating the [ ] :

Following your example:

$("input[numero='"+$("#jugada").val()+"'][name='prueba']").each
    
answered by 02.11.2018 в 14:46