JavaScript Reference/Javascript Methods/remove — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:22, 26 мая 2010
"remove()" Example
<!--
Example revised from
The Web Programmer"s Desk Reference
by Lazaro Issi Cohen and Joseph Issi Cohen
ISBN: 1593270119
Publisher: No Starch Press 2004
-->
<html>
<body>
<script language="JavaScript">
function function1() {
var newOption = document.createElement("<option value="TOYOTA">");
document.all.mySelect.options.add(newOption);
newOption.innerText = "Toyota";
}
function function2() {
document.all.mySelect.options.remove(0);
}
</script>
<select id="mySelect">
<option value="HONDA">Honda</option>
<option value="ACURA">Acura</option>
<option value="LEXUS">Lexus</option>
</select>
<input type="button" value="Add" onclick="function1();">
<input type="button" value="Remove" onclick="function2();">
</body>
</html>
"remove()" is applied to
Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_To |areas* controlRange* |
| |options* <select> |
+----------------+--------------------------------------------------------------+
"remove()" Syntax, Parameters and Note
Note:
Removes the specified element from a collection or <select> element.
Syntax:
document.all.selectID.remove(param1)
collectionName.remove(param1)
Parameters:
param1 Required; the index of the element to remove.