user3244853
user3244853

Reputation: 13

How to resize an input box in Javascript

i have create an input box in java script like this: text.appendChild(document.createElement("input"));

i try to re-size with: text.size = '10'; but it is not working

Upvotes: 0

Views: 89

Answers (1)

Quentin
Quentin

Reputation: 944321

size is a property of the <input>. You're trying to apply it to the container you put the input in.

You need to either keep a reference to the input (by assigning it to a variable instead of passing the return value of createElement to appendChild) or find a new one (e.g. through getElementsByTagName) and set the size on that.

Upvotes: 2

Related Questions