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

  • SEARCH
  • Home
  • 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 7962667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:24:08+00:00 2026-06-04T05:24:08+00:00

Just trying to change the value of an input using jQuery. Seems to work,

  • 0

Just trying to change the value of an input using jQuery. Seems to work, however, when I look at the value of #input using Firebug, it remains at the original value. Is this normal, or am I doing something wrong? Thank you

http://jsfiddle.net/tsfSg/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> 
<title>Testing</title> 
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script> 

$(function(){
    $("#DoIt").click(function()
    {
        $('#input').val('final');
        console.log($('#input'));
        alert($('#input').val());
    });
});

</script>
</head>

<body>
<a href="#" id="DoIt">DoIt</a>
<input id="input" type="text" value="original" />
</body> 
</html>
  • 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-06-04T05:24:10+00:00Added an answer on June 4, 2026 at 5:24 am

    Use .val(): console.log( $('#input').val() );

    $(function(){
        $("#DoIt").click(function(){
            $('#input').val('final');
            console.log($('#input').val());  // the fixed line!
            alert($('#input').val());
        });
    });
    

    demo


    EDIT

    Now I understand at what you are looking: inside the element source (inspect element) in Firebug.
    Well, if you want to see the change actually happen you’ll have to use:

    $('#input').attr('value','final');
    

    instead of:

    $('#input').val('final');
    

    otherwise the change is stored by the browser (nothing to be afraid of) but not updated by Firebug.

    in this demo you can see it working:
    

    demo

    $("#DoIt").click(function(e){
        $('#input').attr('value','final');     // use .attr() to see the change happen in Firebug!
        // $('#input').val('final');           //  but rather use this
        // $('#input').prop('value','final');  // or better THIS one!
        console.log( $('#input').val() );
        alert( $('#input').val() );
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to fire an event when an input changes value using jQuery
Using jQuery, I'm trying to change the selected option in a SELECT element to
I'm trying to change the value of a text input field based on user
I'm trying to setup user authentification in Jquery Mobile/Coldfusion8. I'm using Coldfusion for just
I am trying to set the selected value in a dropdownlist using jquery, I
Just trying to get diff to work better for certain kinds of documents. With
just trying to test for equality in this piece of code, but getting a
Just trying to confirm an impression: it seems enums in EF5 + Code First
I am getting strange behaviour when trying to upload files, using jQuery multi-file plugin,
I am just trying a simple application, to make the browser fullscreen. this is

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.