Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/06/2014, 11:44
Avatar de livemusic
livemusic
 
Fecha de Ingreso: abril-2011
Ubicación: Lima - Chorrillos
Mensajes: 150
Antigüedad: 13 años
Puntos: 18
Respuesta: Cómo puedo "cortar" y separar el name de un input?

Espero y te funcione ...

Código Javascript:
Ver original
  1. $( "input[name=xD]" ).click(function(e){
  2.         // --> SelectInput      --> $('input[name=Rad1us]')
  3.         // --> SelectInputArray --> $('input[name="data[Modelo][Valeria]"]')
  4.  
  5.         var getNames = '';
  6.  
  7.         // :input --> Select all input or input type text == input:text
  8.         $(':input').each(function() {
  9.           var nameInput = $(this).attr('name'),
  10.               lastBracket = nameInput.split('[').pop().replace(']', '');
  11.  
  12.           getNames += lastBracket +' ';
  13.         });
  14.  
  15.  
  16.         console.log(getNames);
  17.         e.preventDefault();
  18.       });

-----------------------------------------------

Código HTML:
Ver original
  1. <input type="text" name="data[Rad1Us][Valeria]" /> <br />
  2.   <input type="text" name="data[gracias][thanks]" /> <br />
  3.   <input type="text" name="data[por][for]" /> <br />
  4.   <input type="text" name="data[todos][all]" /> <br />
  5.   <input type="text" name="data[momentos][moments]" /> <br />
  6.   <input type="button" name="xD" value="u_u" />

:'c ...