Reputation: 460
I'm having a problem with printing a text string to a input tag.
The javascript:
imgDiv.innerHTML += "<input type='text' value=" + text[i].firstChild.data + ">";
The generated html looks like this:
<input type="text" fjäril="" svart="" och="" orange="" value="En">
Does anyone have a suggestion on what is causing this problem?
Upvotes: 0
Views: 467
Reputation: 44581
value
attribute's value should be also wrapped in quotes (like you did with type
attribute):
imgDiv.innerHTML += '<input type="text" value="' + text[i].firstChild.data + '">';
Upvotes: 2