Rails 4-简单表单-Jquery-如何向选择框中的选项添加类
我很困惑,非常感谢你的帮助。请告诉我如何将类添加到选择框中的特定选项 如图所示,我只想在选项中添加一个类:Rails 4-简单表单-Jquery-如何向选择框中的选项添加类,jquery,ruby-on-rails,Jquery,Ruby On Rails,我很困惑,非常感谢你的帮助。请告诉我如何将类添加到选择框中的特定选项 如图所示,我只想在选项中添加一个类:X男X女,但我不确定如何添加 _form.html.erb <%= simple_form_for [@user, @social] do |f| %> <%= f.error_notification %> <div class="form-inputs"> <%= f.association :category_quantity
X男X女
,但我不确定如何添加
_form.html.erb
<%= simple_form_for [@user, @social] do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.association :category_quantitygender, collection: CategoryQuantitygender.all, prompt: "select a category", label: "Quantity Gender Selection", input_html: { class: 'category_select' } %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
请按照选择框中添加类的链接进行操作试试这个
$('#social_category_quantitygender_id').find("option[value='4']").addClass("here")
希望这对你有用………谢谢@akshay!你的答案是最好的,因为它允许我将一个类放在一个特定的选项值上。非常感谢你@阿特洛:谢谢你:)
$('#social_category_quantitygender_id').find("option[value='4']").addClass("here")