I got the impression that "val ()" should be used for the input element, and "text ()" should be used for all other elements.
However, when I do the following:
$("<input/>").val("test")
I get
[<input>]
and when I go to the following:
$("<input/>").text("test")
I get
[<input>test</input>]
The last is what I am looking for.
Is there anything else when using jquery to create an element that I am missing? My actual situation is much more complicated than this, but I simplified it for the purposes of this question.
source
share