Input element in javascript
How to set the size or width of an input element in javascript.
I am using input_obj.size= '40%'开发者_JAVA百科
;
But, it is not working.
You set the size as per your own example — but it doesn't take a CSS length. It takes an integer (number of characters).
The width is set as per any other element: input_obj.style.width
.
You should use style attribute:
input_obj.style.width = '40%';
If input_obj is your input obj (which I assume according to the name ;))
input_obj.style.width = '100px';
精彩评论