Is there a css selector to match a option value of the select tag?

喜夏-厌秋 提交于 2020-08-01 09:51:06

问题


For example:

<select>
<option value="one">1</option>
<option value="two">2</option>
<option value="three">3</option>
</select>

I want to select the option where value = one, but I must select using the value attribute.

I've tried a few variations as the ones below:

option[value="one"]{
}

select[value="one"]{
}

select option[value="one"]{
}

回答1:


option[value=two] { 
    background-color: yellow;
}
<select>
<option value="one">1</option>
<option value="two">2</option>
<option value="three">3</option>
</select>


来源:https://stackoverflow.com/questions/31619048/is-there-a-css-selector-to-match-a-option-value-of-the-select-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!