I am not sure whether this only happens to me. Basically if I have a new element added to the page using YUI
var element = new YAHOO.util.Element(document.createElement('input'));
element.set('value', 'some value');
element.appendTo(document.body);
Then I read the value of the element using these different ways, and get consistent result
element.get('value'); // get 'some value'
element.get('element').getAttribute('value'); // get 'some value'
element.get('element').value; // get 'some value'
// jquery as reference
jQuery(element.get('element').val()); // get 'some value'
If I change the field value through the browser (for example, 'new value'), and repeat the above steps again, i get some interesting values
element.get('value'); // get 'some value'
element.get('element').getAttribute('value'); // get 'some value'
element.get('element').value; // get 'new value'
// jquery as reference
jQuery(element.get('element').val()); // get 'new value'
However, if the input element is already exists in the page and is currently holding user input -> 'some value'
var element2 = new YAHOO.util.Element('some_input');
First read get same result as above scenario
element.get('value'); // get 'some value'
element.get('element').getAttribute('value'); // get 'some value'
element.get('element').value; // get 'some value'
// jquery as reference
jQuery(element.get('element').val()); // get 'some value'
if the user enters 'new value' to the input field through the browser, then repeating the above steps gets
element.get('value'); // get 'new value'
element.get('element').getAttribute('value'); // get 'new value'
element.get('element').value; // get 'new value'
// jquery as reference
jQuery(element.get('element').val()); // get 'new value'
I am just wondering why would I get different values for dynamically generated element if different way of retrieving data is used, or it is just because I am doing it wrong?