Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3695522
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:37:41+00:00 2026-05-19T04:37:41+00:00

If I change an inputs value and want to reset it back to the

  • 0

If I change an inputs value and want to reset it back to the original value onClick of a link how can I accomplish that?

I can use .data() to grab and store the original value but I am not sure of the best way to restore it if needed.

HTML:

<input class="someClassName" type="text" value="100" /> 
<a href="#">Edit</a>
<a href="#">Reset</a>

This is how I think it would work…

In the HTML above, the input will be rendered with a value of “100”. If I then click “edit” I can use .date() to store the original value (100). I can then change the value of the input but if I wanted to reset the value back it’s original state I would need to call the .data() info and use it to restore the value of the input.

How would I do that using jQuery?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:37:41+00:00Added an answer on May 19, 2026 at 4:37 am

    using .data is perfect for that. look no further

    update – with some code directions

    Assuming you want to have this done for many input fields and not just one I am assuming each input+edit+reset are contained in a single parent

    <div>    
        <input class="someClassName" type="text" value="100" /> 
        <a class="EditLink" href="#">Edit</a>
        <a class="ResetLink" href="#">Reset</a>
    </div>
    

    and in your init script block

    $(".EditLink").click(
                 function() {
                    $(this).parent().children("INPUT").data("val",
                      $(this).parent().children("INPUT").val());
                 });
    $(".ResetLink").click(
                 function() {
                    $(this).parent().children("INPUT").val(
                      $(this).parent().children("INPUT").data("val"));
                 });
    

    I didn’t test it but it should work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to reset an input field back to its original
There are many ways the value of a <input type="text"> can change, including: keypresses
Should I use the change or textInput event to capture user input on a
i have an input element, and i want bind both change and keypress event
Change Data Capture is a new feature in SQL Server 2008. From MSDN: Change
How can I change the title of the command prompt window every time I
How can I change default Generate Method Stub behavior in Visaul Studio to generate
What's the best way to implement user controls that require AJAX callbacks? I want
I have a form that I want to be used to add entries. Once
I've a few inputs and I want to clear their values after clicking. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.