In an input
element, the value of can be found in a value
property of that element. It can therefore be retrieved via document.getElementById('idOfElement').value
.
In an textarea
element has it's value between the starting and the closing tag. Therefore, the value
property is empty. In raw javascript, you would be able to retrieve the contents with document.getElementById('idOfElement').innerText
.
If you are however using jQuery, Ufuk's solution with .val()
is much easier to use.