How to addClass('ui-state-error') to a <select> styled with selectmenu, dropkick and/or chosen plugin?

后端 未结 1 739
陌清茗
陌清茗 2021-01-26 09:58

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

I\'d like to

相关标签:
1条回答
  • 2021-01-26 10:32

    See my JSFiddle here.

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

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

    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!

    0 讨论(0)
提交回复
热议问题