Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
Uso del mapa para obtener todos los valores de los campos de entrada

Digamos que hay numerosos <input> y quería todos los valores como una matriz. Pensé que sería muy fácil simplemente hacer $("input").map(function(obj) { $(obj).val() }) , pero cuando obtengo eso, aparece el error: Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase')

Este error está ocurriendo dentro de jQuery aquí:

 var rreturn = /\r/g; jQuery.fn.extend({ val: function( value ) { var hooks, ret, isFunction, elem = this[0]; if ( !arguments.length ) { if ( elem ) { hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; ...

Cualquier trabajo alrededor? Aquí hay un violín: https://jsfiddle.net/jvbgo94f/1/

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Un poco diferente de lo que está buscando, pero la forma estándar de manejar esto es usar FormData .

Si envuelve sus entradas en un elemento de formulario:

 <form> <input name="a" /> <input name="b" /> <input name="c" /> </form>

Entonces, puedes hacer algo como esto:

 const formData = new FormData( document.querySelector('form') ); for (const [key, value] of formData) { console.log({key, value}); }
about 4 years ago · Juan Pablo Isaza Report

0

Debe usar $(this) dentro del mapa para acceder a ese elemento en particular.

 $("#a").val("1"); $("#b").val("2"); inputs = $(".test").map(function() { return $(this).val(); }); console.log($(inputs));
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input class="test" id="a" /> <input class="test" id="b" /> <input class="test" id="c" />

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!