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

189
Vistas
how to set previousvalue attribute in input tag using jquery

is there any solution to set value for previousvalue attribute for input field using javascript or jquery in the browser console?

I am trying to set the value to input field it's working but at the same time, I need to set the value to previousvalue attribute which is in the tag.

     <input type="text" value="" id="test" previousvalue=""/>  

to set value i am using document.getElementById("test").value="add";

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

<input id="input" type="text" value="" previousvalue="" />
document.getElementById('input').addEventListener('change', function() {
    this.previousvalue = this.value;
    const { value, previousvalue } = this;
    console.log(value, previousvalue);
});

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you mean you want value and previousvalue have the same value you can do it like this (imagine input has inp id):

const input = $('#inp')
input.attr('previousvalue', input.attr('value'))

generaly you can set attribute of tag in JQ like below structure:

$(el).attr('attr-name', 'attr-value');\

in pure JS you can do it like this:

el.setAttribute('attr-name', 'attr-value');
about 4 years ago · Juan Pablo Isaza Denunciar
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