Reputation: 1257
how one can assign class="some_class" to option in select box?
i would like to have
<select class="my_class" name="example">
<option selected="selected" value="">Choose something ...</option>
<option value="1" class="some_class">Hello</option>
<option value="2" class="some_class">World</option>
</select>
But I don't have any idea how to do it.. my form looks like:
{{ Form::select('example', array('1' => 'Hello', '2' => 'World'), null, array('class' => 'my_class', 'placeholder' => 'Choose position ...')) }}
How can I add "some_class" attribute to OPTION menu ?
Upvotes: 1
Views: 925
Reputation: 163898
You can use my_class
similar to this:
.my_class select option{
font-size: 20pt;
color:red;
}
This will affect only <option>
elements of your <select>
element.
Also, you can use JS to do this.
Upvotes: 0
Reputation: 15457
The Form builder doesn't support class attributes for option
tags. You will either need to build the select
manually, or use JavaScript / jQuery to add the class to the option
tags.
Upvotes: 1