我正在使用CSS来为我的HTML页面添加样式。
我能用选择器:
form input[type="text"]
改变一个输入框的类型从文本(text)到其他类型?只需更改其中一个,其他的都使用 CSS 实现即可。
我正在使用CSS来为我的HTML页面添加样式。
我能用选择器:
form input[type="text"]
我不太明白你的问题。但是你有几个选择
将每个输入的文本都进行样式设置。<input type="text" />
form input[type="text"] {}
将首先为输入的文本设置级别样式
form >input[type="text"] {}
将仅样式化第一个输入框
form input[type="text"]:first-child {}
将使用类名为“foo”的样式来装饰输入的文本
form input.foo[type="text"] { }
所以,假设你有一个表单。
<form action="" method="POST">
<input type="text" name="text" class="foo" />
<input type="text" name="text2" class="bar" />
</form>
这将针对所有输入进行定位
form input[type="text"] { border:2px solid #000000; }
这将仅针对具有类“foo”的第一个输入进行定位。
form input.foo[type="text"] { background-color:red; }
这将针对具有类名为“bar”的第二个输入进行目标设置。
form input.bar[type="text"] { background-color:green; }
您可以使用
input[type="text"]
input[type="button"]
input[type="password"]
input[type="number"]
input[type="email"]
input[type="text"] {
width: 150px;
display: block;
margin-bottom: 10px;
background-color: yellow;
}
type="mail"
,而是email
。 - putvanderesetForm(e) {
const searchInput = this.formSearchUser.querySelectorAll('input[type="text"]');
searchInput.forEach((elt) => {
console.log(`${elt.name} = ${elt.value}`);
if (elt.name !== "siteCode" || elt.name !== "expiredUsers")
elt.value = '';
});
<form>
内且具有type="text"
的<input/>
元素。 - putvande