开发者

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';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜