grails select tag突出显示之前设置的值

时间:2016-05-05 20:01:03

标签: grails

在表单选择标记中,我希望突出显示当前持久值,以便用户在开始选择不同选项时可以记住哪一个是持久值。

<select>
  <option>You can pick this one...</option>
    <option>..or this one...</option>
   <option style='background:yellow'>..this one highlighted b/c you saved it last time...</option>
  </select>

有人用grails完成了这个吗?你可以为此使用grails select标签,还是我必须建立自己的标签?

1 个答案:

答案 0 :(得分:1)

您可以使用value属性

  

value(可选) - 当前选定的值,用于评估from列表中某个元素的equals()为true。

所以现在持久性选项具有selected属性,您可以使用CSS设置样式: 例如:

<g:select name="name" from="${1..5}" value="2"></g:select>

CSS:

option[selected]{
    background-color: yellow;
}
相关问题