The is the beauty of JavaScript. The value is not being store anywhere as you would think! This is the magic of 'closures'.
Closure is basically the concept of a variable being alive even after it's scope has ended.
For example:
function outerFunction() {
innerVar = function innerFunction() {
alert('hello');
}
return innerVar;
}
var outterVar = outerFunction();
outterVar();
The above will output 'hello'. Note, the outerFunction has finished executing and the scope of 'innerVar' is also over; however, interestingly we can still execute a function defined in the outer function.
Similarly, when you pass a function to parent.register, you are NOT passing the actual value obtained by 'val()'; you are passing a function which will later be executed and internally will act as a a closure.
When it does get executed, it then takes the value by using 'val()' of the element present inside that 'closure' function.