列表左右移動 2017-03-23

來源:互聯網
上載者:User

標籤:索引   左右移動   cal   分享   左移   賦值   藍色   技術   end   

<body>

<select id="s1" size="10" >

<option>紅色</option>

<option>綠色</option>

<option>藍色</option>

<option>黑色</option>

<option>白色</option>

</select>

 

<select id="s2" size="10" >

<option>蘋果</option>

<option>香蕉</option>

<option>桃子</option>

<option>梨</option>

<option>橙子</option>

</select><br />

<input type="button" id="t1" value="右移" />

 

        <input type="button" id="t2" value="左移" />      

         <script>

document.getElementById("t1").onclick=function(){    -----右移

var op=document.getElementById("s1").selectedOptions;---------將選中的資料賦值給op

document.getElementById("s2").appendChild(op[0]);  ------表示選中的資料中索引值為0

document.getElementById("s1").removeChild(op[0]);

}

document.getElementById("t2").onclick=function(){   ----左移

var op=document.getElementById("s2").selectedOptions;

document.getElementById("s1").appendChild(op[0]);

document.getElementById("s2").removeChild(op[0]);

}

</script>

</body>

列表左右移動 2017-03-23

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.