<form>
<textarea name="test" value="no">
hi
</textarea>
<input type="submit" />
</form>
hi or no,and reason?
I ask this question because I see javascript editors use textarea.value = html; to restore the content when submit,why they do this if value attribute is useless?
hiwill be submitted. There is novalueattribute for the<textarea>tag. See W3School’s textarea tag reference for details.To answer your question of why you see javascript libraries accessing the
valueproperty of a textarea DOM element, you have to appreciate that HTML and the DOM (Document Object Model) that javascript accesses are 2 different animals. In HTML the value of a<textarea>is its contents. In DOM, the value of a textarea node is contained in itsvalueproperty. Although DOM property names often map 1:1 to HTML attribute names, they don’t always and this is just one example.