我想在SELECT标签中选择一种具有特殊颜色的选项。
如何在使用Rails的f.select帮助器和options_for_select后执行此操作?
<html>
<head>
<style type="text/css">
option.standard {background-color:#FFAAAA}
</style>
</head>
<body>
<select style="width:100px">
<option selected="selected">1</option>
<option>2</option>
<option class="standard">3</option>
<option>4</option>
<option>5</option>
</select>
</body>
</html>
答案 0 :(得分:3)
正如文档中提到的options_for_select
,您可以这样做:
options_for_select([ 1, 2, [ 3, { :class => 'standard' }], 4, 5 ], [ 1 ])