私はとても混乱しています。選択ボックス内の特定のオプションにクラスを追加する方法を親切に教えてください。 <option value="4">both X men & X women</option>
をしかしRails 4 - Simple Form - Jquery - 選択ボックス内のオプションにクラスを追加する方法
_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 %>
iは下記が、運試したどのように私はわからないよ:
画像を1として、私は唯一のオプションにクラスを追加したいと思います:
$(document).ready(function() {
$('#social_category_quantitygender_id').addClass($('here').val() == 4));
});
.............これはあなたのために働くことを願っています
......これを試してみてくださいありがとう@akshay!特定のオプション値にクラスを配置できるので、あなたの答えは最高です。多くのsooをありがとう! – ARTLoe
@ARTLoe:ありがとうございました:) –