简体   繁体   中英

Set data-theme programatically on textbox in Jquery Mobile

Is there a way to set the "data-theme" of a textbox in 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/

To conform to jquerymobile standards I would use:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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