比较html中文本框的大小 [英] Comparing the size of textboxes in html

查看:200
本文介绍了比较html中文本框的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我的示例输入文件是

标签名称:input
属性:
type ="text"
name ="hello"
size ="49"

标签名称:input
属性:
type ="text";
name ="hello'';
size ="50";

现在如何比较两个文本框的大小...从标记名=输入和属性类型=文本"....(大小= 49 &&大小= 50),在这种情况下导致不匹配结果

Say for example my sample input file is,

Tag name: input
Attributes:
type="text"
name="hello"
size="49"

Tag name: input
Attributes:
type="text";
name="hello'';
size="50";

Now how can i compare the size of the two textboxes... from the Tag name=input and attribute type="text" ....(size=49 && size=50)and results a mismatch result in this case

推荐答案

您无法在HTML中做到这一点.但您可以使用Javascript完成此操作.您所要做的就是在文本框上放置一个ID属性,然后可以使用此代码获取宽度.将文本框的ID放在getElementById函数的参数上.

You can''t do that in HTML. but you can do it in Javascript. All you have to do is to put an ID attribute on your textboxes, and then you can use this code to get the width. Put the id of the textbox on the parameter of the getElementById function.

var someTextBox = document.getElementById("textBox1");
someTextBox.style["width"] = "20px";


这篇关于比较html中文本框的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆