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

187
Views
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 answers
Answer question

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 Report

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 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!