0
在jQuery Validate插件中,设置errorClass
设置错误消息和输入元素的类。无论如何只为错误消息元素设置类?只在jQuery验证插件中自定义错误消息元素的类
在jQuery Validate插件中,设置errorClass
设置错误消息和输入元素的类。无论如何只为错误消息元素设置类?只在jQuery验证插件中自定义错误消息元素的类
不,该插件动态地将errorClass
添加到输入和错误消息元素,并且您无法更改此行为,您也不需要更改它。毕竟,对元素进行类化之前不会做任何事情,除非您创建一些以它们为目标的CSS属性。
所以通过使用正确的CSS选择器,您可以轻松地单独定位这些元素。
为缺省设置errorClass
,这是"error"
沿验证消息的默认label
容器......
label.error {
/* CSS properties targeting only the error messages */
}
select.error,
textarea.error,
input[type="text"].error,
input[type="radio"].error,
input[type="checkbox"].error {
/* CSS properties targeting only the input elements */
}
DEMO:http://jsfiddle.net/j3te0d10/
反正是有设定只有错误消息元素的类?
你永远不需要这样做。
只需在您的CSS中指定label.error
并且只有错误消息会受到影响。
label.error {
/* CSS properties targeting only the error messages */
}