使用频率 | 极低 |
所属模块 | Std.css |
成员类型 | 静态成员变量 |
Std.css.pseudos保存的是css选择器的所有伪类,例如当执行选择器 "input:focus" 的时候就会在Std.css.pseudos中找到函数 "focus"
可以通过Std.css.pseudos增加自定义css选择器伪类,例如需要在通过Std.dom方法找到一个属性view值为text的div元素的时候,可以这样做:
Std.css.pseudos["my"] = function(element){
return element.getAttribute("view") == "text";
}
Std.css.pseudos中的所有函数返回值均是一个Boolean值.
当增加了自定义伪类"my"之后,就可以通过Std.dom("div:my('text')") 得到属性view值为text的div元素了.
需要注意的是,伪类如果包含参数,并且参数是字符串,需要用 ' 或者 " 将其包含起来,如果需要有'或"字符串,可以在前面加上\反斜杠进行转义, 与js执行函数方式一样,这是StdJS实现与传统实现的不同之处.
通常情况下,其中包含的方法不会被直接形式的用到.
方法名称 | 成员类型 | 描述 |
::active | static | 是否为active状态 |
::checked | static | 是否拥有checked状态 |
::contains | static | 是否包含指定文本 |
::disabled | static | 是否禁用状态 |
::empty | static | 是否不包含子元素 |
::enabled | static | 是否没有禁用 |
::even | static | 索引值是否偶数 |
::first-child | static | 是否为第一个子元素 |
::first-of-type | static | 是否父元素的第一个该类型元素 |
::focus | static | 是否拥有焦点 |
::has | static | 是否包含指定选择器 |
::html | static | html内容判断 |
::hidden | static | 是否隐藏状态 |
::index | static | 是否指定的索引值 |
::last-child | static | 是否为最后一个元素 |
::last-of-type | static | 是否父元素的最后一个该类型元素 |
::not | static | 是否与指定选择器不匹配 |
::nth-child | static | 是否与指定参数相匹配 |
::nth-last-child | static | 是否与指定参数相匹配(从后往前) |
::nth-last-of-type | static | nth-last-of-type选择器 |
::nth-of-type | static | nth-of-type选择器 |
::odd | static | 索引值是否基数 |
::only-child | static | 是否最后一个元素 |
::only-of-type | static | 是否唯一类型的子元素 |
::parent | static | 是否为父元素 |
::password | static | type类型是否为password |
::read-only | static | 是否只读的 |
::read-write | static | 是否可读写的 |
::root | static | 是否为documentElement |
::selected | static | 是否selected状态 |
::target | static | id值是否为文档hash |
::text | static | 是否文本输入框 |
::value | static | value值是否为指定值 |
::visible | static | 是否为可见状态 |