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 */
}