Skip to content

Instantly share code, notes, and snippets.

@movii
Last active June 23, 2017 15:32
Show Gist options
  • Save movii/8d789dccd59f17ce6e724d844c7a78d4 to your computer and use it in GitHub Desktop.
Save movii/8d789dccd59f17ce6e724d844c7a78d4 to your computer and use it in GitHub Desktop.
使用 CSS 伪类为 select 元素添加 placeholder: 2. onchange event with javascript
<select onchange="this.className=this.options[this.selectedIndex].className" class="placeholder">
<option value="" selected class="placeholder">placeholder</option>
<option value="1" class="green">green</option>
<option value="2" class="red">red</option>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment