$('#inputElement').text() returns empty string and a solution for it

$('#inputElement').text() returns empty string and a solution for it


Dear jQuerians,
I have learned about jQuery a couple of days and now I am using it all
over my code ;-).
I have a problem and a solution.
Then I use $('#inputElement').text() to get the value of an input
element, I receive an empty string. It turns out it is because:
1) the text function is extracting the text only from the children
nodes.
2) .nodeValue is used to get the content of the DOM node that in case
of INPUT element returns an empty string.
The solution I am proposing is to here http://paste.pocoo.org/show/111208/
It deals with two cases - when there are children elements or not and
it checks for bouth .value attribute and .nodeValue attributes.
I hope this will help.
Regards,
Thomas