如何将Class('ui-state-error')添加到< select>用selectmenu,dropkick和/或选择的插件设置样式? [英] How to addClass('ui-state-error') to a <select> styled with selectmenu, dropkick and/or chosen plugin?

查看:84
本文介绍了如何将Class('ui-state-error')添加到< select>用selectmenu,dropkick和/或选择的插件设置样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些插件(selectmenu,dropkick,selected,可能还有更多)可以将标签组合框变成更漂亮,样式更多功能的版本.

There are a few plugins ( selectmenu, dropkick, chosen, and probably many more ) that turn tag combo-box into a prettier, styled, more functional version.

我想用ui-state-error样式设置扩展标签的样式.有时这偶尔会起作用,但在大多数情况下却无效:

I'd like to style the extended tag with ui-state-error style. This sporadically works sometimes, but most of the time it doesn't:

$('select').selectmenu().addClass('ui-state-error');

即使它起作用,removeClass('ui-state-error')也不起作用.

And even when it works, removeClass('ui-state-error') doesn't work.

那么,将Class('ui-state-error')添加到这些扩展组合框之一的正确方法是什么?

So, what is the correct way to addClass('ui-state-error') to one of these extended combo-boxes?

推荐答案

请参见我的JSFiddle 此处.

See my JSFiddle here.

据我所见,您应该使用以下内容:

From what I can see, you should use the following:

 $('select').selectmenu();
 $('.ui-selectmenu').addClass('ui-state-error');

这将达到您想要的效果,但是当您在页面上有多个选择时,它将引起问题.在这里,您可以深入了解每个实现的细节.至于selectmenu,看来您应该能够执行以下操作:

This will achieve the effect you desire, but it's going to cause an issue when you have multiple selects on the page. This is where you get into the specific of each implementation. As for selectmenu, it seems you should be able to do the following:

 id = $('select')[0].id;
 $('#' + id + '-button').addClass('ui-state-error');

但是,这是在很少文档的插件上非常具体的.随意使用它作为起点.享受吧!

But, that's very specific on a plugin with very little documentation. Feel free to use this as a jumping off point. Enjoy!

这篇关于如何将Class('ui-state-error')添加到< select>用selectmenu,dropkick和/或选择的插件设置样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆