Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/09/2016, 14:39
mpozo
 
Fecha de Ingreso: noviembre-2015
Mensajes: 231
Antigüedad: 8 años, 5 meses
Puntos: 86
Respuesta: Cómo modificar TODOS los TAGS "input" de un archivo HTML ???

Es algo sencillo de hacer. Un par de nociones básicas y ya está
Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <html dir="ltr" lang="es-es">
  3.     <head>
  4.         <title></title>
  5.         <meta charset="utf-8">      
  6.     </head>
  7.     <body>
  8.  
  9.         <form>
  10.             <input type="text" value="foo">
  11.             <input type="text" value="bar">
  12.             <input type="text" value="candy">
  13.         </form>
  14.  
  15.         <script>
  16.             Array.prototype.forEach.call(document.querySelectorAll('input[type="text"]'), function(e, i, a){
  17.                 a[i].addEventListener('focus', function() {
  18.                     this.select();
  19.                 }, false);
  20.             });
  21.         </script>
  22.  
  23.     </body>
  24. </html>