和tianlebest的一样,我用的是创建节点的方法,可怎么也获取不到sel1中option的文本内容,请朋友们帮忙解答,谢谢
<table width="340">
<tr>
<td align="center" width="120">
<select size="12" style="width:120px" id="sel1">
<option value="品种1">品种1</option>
<option>品种2</option>
<option>品种3</option>
<option>品种4</option>
<option>品种5</option>
<option>品种6</option>
<option>品种7</option>
<option>品种8</option>
<option>品种9</option>
<option>品种10</option>
<option>品种11</option>
<option>品种12</option>
<option>品种13</option>
<option>品种14</option>
<option>品种15</option>
<option>品种16</option>
<option>品种17</option>
<option>品种18</option>
<option>品种19</option>
<option>品种20</option>
</select>
</td>
<td align="center" width="100" valign="middle">
<input type="button" id="but1" value=">>" style="width:50px;" onclick="add('sel2',str)"><br/><br/>
<input type="button" id="but2" value="<<" style="width:50px;">
</td>
<td align="center" width="120">
<select size="12" style="width:120px" id="sel2">
</select>
</td>
</tr>
</table>
<script language="javascript">
var x=document.getElementById("sel1");
var str=x.selectedIndex.value;
function createnew(str)
{
var newElement=document.createElement("option");
var newText=document.createTextNode(str);
newElement.appendChild(newText);
return newElement;
}
function add(nodeId,str)
{
var node=document.getElementById(nodeId);
var newNode=createnew(str);
node.appendChild(newNode);
}
</script>
習慣瞇醉,禧歡跟上帝窷兲,像变澀龙般虚伪,如气候那样善变.人脸背后流淌着恶魔的血,一路向前,猦猦癫癫.