Created
April 23, 2014 08:49
-
-
Save FrankFan/11207588 to your computer and use it in GitHub Desktop.
js set option background color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Javascript quiz</title> | |
<meta charset="utf-8"> | |
<script type="text/javascript"> | |
/* | |
* 要求: | |
* how to use js to set the backgournd color of the | |
* sencond option(value="b") to be grey? | |
*/ | |
function setColor () { | |
var option = document.getElementsByTagName("option"); | |
option[1].style.backgroundColor = "gray"; | |
} | |
</script> | |
</head> | |
<body> | |
<div> | |
<select> | |
<option value="a">Hello</option> | |
<option value="b">World</option> | |
</select> | |
<input type="button" value="set color" onclick="setColor()"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment