Last active
August 29, 2015 14:07
-
-
Save TzuYangLin/d6ac206b436e0894ccc7 to your computer and use it in GitHub Desktop.
Example: How to delete the option of select
This file contains hidden or 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> | |
<meta http-equiv=Content-Type content="text/html; charset=utf-8"> | |
<script language="JavaScript"> | |
function test() | |
{ | |
var select = document.getElementById("test"); | |
for(i=select.options.length-1;i>=0;i--) | |
{ | |
select.remove(i); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<select id="test"> | |
<option value=0>0</option> | |
<option value=1>1</option> | |
<option value=2>2</option> | |
<option value=3>3</option> | |
<option value=4>4</option> | |
<option value=5>5</option> | |
</select> | |
<input type=button value="test" onClick="test();"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment