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

158
Views
log $(this).val() in Jquery

I found a fiddle that logs when an input field changes value. However i would like to log the new value as well. I have tried all the combinations i found online, but cant get it to work. here is a fiddle: https://jsfiddle.net/XezmB/8/

index

<input type="number" id="n" value="5" step=".5"/>

script

    $(":input").bind('keyup change click', function (e) {
    if (! $(this).data("previousValue") || 
           $(this).data("previousValue") != $(this).val()
       )
   {
        console.log("changed");           
        $(this).data("previousValue", $(this).val());
   }
        
});


$(":input").each(function () {
    $(this).data("previousValue", $(this).val());
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do that by changing the 6th line of your shared code.

From:

console.log("changed");           

To:

console.log("changed: ", $(this).val() );           
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!