在表单选择标签中,我希望突出显示当前的持久值,以便用户在开始选择其他选项时可以记住哪一个是持久值。
<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 select标签,还是我必须构建自己的标签?
最佳答案
您可以使用value
属性
value (optional) - The current selected value that evaluates equals() to true for one of the elements in the from list.
因此,现在持久选项具有
selected
属性,您可以使用CSS设置样式:例:
<g:select name="name" from="${1..5}" value="2"></g:select>
CSS:
option[selected]{
background-color: yellow;
}
关于grails - grails选择标签突出显示先前设置的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37059252/