Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

283
Vistas
Cómo restar texto de manera procesal, luego repoblar dicho texto hasta cierta cantidad

Tengo este script que crea un efecto de "escribir" cuando se implementa. Quiero que pueda eliminar la última palabra de la oración y luego "volver a escribir" esa sección con una nueva palabra. Entonces, por ejemplo, se escribe algo como "Este es el texto original" y luego elimina las últimas 4 letras de la misma manera que lo escribió, y lo reemplaza con "Este es el guión original", si eso tiene algún sentido. .

máquina de escribir.js:

 var arrText = new Array("This is the original text"); // Array of text to be "typed" var speed = 80; // Delay speed as text "types" out. Lower value = faster speed var index = 0; // Start position for the typing effect var arrLength = arrText[0].length; // Length of the text array var textPos = 0; // Initialize text position var contents = ""; // Initialize contents variable function typewriter() { // Aqcuire the destination of the typewriter ID var destination = document.getElementById("typewriter"); // Initiate the innerHTML of the destination, with an initial carat value destination.innerHTML = contents + arrText[index].substring(0, textPos) + "<span class='blink'>█<span>"; // If textPos hasn't reached the array length, increase textPos value if (textPos++ != arrLength) { setTimeout("typewriter()", speed); } else { // Subtract text code here??? } } // Wait specified time (in milliseconds) before starting script setTimeout(typewriter, 500);

índice.html:

 <div id="typewriter"></div>

estilo.css

 .blink { animation: blink-animation 1400ms steps(2, start) infinite; -webkit-animation: blink-animation 1400ms steps(2, start) infinite; } @keyframes blink-animation { to { visibility: hidden; } } @-webkit-keyframes blink-animation { to { visibility: hidden; } }
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda