有没有办法用CSS选择多个输入字段类型? [英] Is there a way to select multiple input field types with CSS?

查看:185
本文介绍了有没有办法用CSS选择多个输入字段类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本和密码输入字段,我试图以这种方式选择:

I have a text and a password input field that I'm trying to select in this fashion:

input[type=text][type=password]

我会避免使用jQuery,所以任何帮助将赞赏(不使用自定义类)。

however this does not work. I would refrain from using jQuery, so any help would be appreciated (without using custom classes).

推荐答案

如果需要,使用逗号重复这些类型:

You need to specify the attributes separately, repeating the types if necessary and using comma(s):

input[type=text], input[type=password]

您的指定选择器尝试匹配输入类型,即 text 密码,但是单个元素对同一个属性不能有不同的值,因此会失败。

Your given selector is trying to match an input with a type that is both text and password, but a single element can't have different values for the same attribute so it fails.

这篇关于有没有办法用CSS选择多个输入字段类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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