开发者

Switching around text input fields with jQuery

开发者 https://www.devze.com 2023-02-16 17:42 出处:网络
I have a text field that uses jQuery UI Datapicker. It also has an inline label from the inline-form-field jQuery plugin.

I have a text field that uses jQuery UI Datapicker. It also has an inline label from the inline-form-field jQuery plugin.

When the plugin is active, it assigns a class to the textbox, called ".intra-field-label". The datepicker also assigns a class called ".hasDatepicker". The first class is supposed to be light grey, and switch to black when text is put into the field. However, the datepicker complicates things. The field's text stays light grey when I enter a date with the datepicker.

H开发者_运维技巧ow can I get around this, so that the date picked from the datepicker widget is black as well?

I need to be able to remove the class .intra-field-label from the text input as soon as a date is picked. How would I do that? Maybe something like focus() -> remove class. If when blur(), and the field has no value, re-add the class. I just don't know that in jQuery if it is even correct.

Any help?


You can use the onClose event of the UI Datepicker which is triggered when the Datepicker is closed.

$('.selector').datepicker({
onClose: function(dateText, inst) { 
$(this).removeClass('intra-field-label');
 }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号