简体   繁体   English

在Jquery Mobile的文本框中以编程方式设置数据主题

[英]Set data-theme programatically on textbox in Jquery Mobile

Is there a way to set the "data-theme" of a textbox in Jquery mobile? 有没有办法在Jquery mobile中设置文本框的“数据主题”?

$("#txtEmail").attr("data-theme", "b");

...doesn't work. ...不起作用。

I like to use this to to display invalid form items in form validation. 我喜欢用它来在表单验证中显示无效的表单项。

You have to manually remove the earlier theme class and add the new theme class after changing the theme. 您必须手动删除较早的主题类,并在更改主题后添加新的主题类。

$("#txtEmail").removeClass("ui-body-c").addClass("ui-body-b");

A demo here - http://jsfiddle.net/vppvG/ 此处的演示-http: //jsfiddle.net/vppvG/

To conform to jquerymobile standards I would use: 为了符合jquerymobile标准,我将使用:

$("#txtEmail").attr('data-theme','b').trigger('refresh'); $(“#txtEmail”)。attr('data-theme','b')。trigger('refresh');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM