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
<!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>
Use
.val():console.log( $('#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:
instead of:
otherwise the change is stored by the browser (nothing to be afraid of) but not updated by Firebug.
demo