Yes, you are right,
provided the text box with id= a had some text on load.
by that I mean something along the lines of
<input type="text" name="a" id="a" value= "foo"/>
Fiddle: http://jsfiddle.net/Jayas/vhjm8v31/2/
Now if you hit Clickhere button it will display foo.
In your case
- When you assign the value of
a to normal the text box is empty.
You dont have any handlers or events hooked up to reset/set the variable normalon something being typed or after something has got typed in. by that I mean something along the lines of having the value stored on input change along the lines of
$(document).ready(function(){
$('#a').bind('input propertychange', function() {
normal = $('#a').val();
}
})
Fiddle http://jsfiddle.net/Jayas/vhjm8v31/4/
tl:dr - rebinding of the text to the declared variable does not "automagically" happen
So now when you click on the button after reassigning normal you will see the typed value.
or alternatively you can capture the value of normal on click event as you already have it , along the lines of
$('#b').on("click", function() {
var normal = $('#a').val();
alert(normal);
});