Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the interchange between left and right menus in html

Shulou Source: shulou.com Published: 2022-06-03 04:09:20 10月01日 Update

This article will explain in detail how to realize the left and right menu interchange of html, Xiaobian thinks it is quite practical, so share it for everyone to make a reference, I hope you can gain something after reading this article.

function selectOne(){// 1. Get the selected element in Select on the left var leftSelect = document.getElementById("leftSelect"); var options = leftSelect.options; //Find Select on the right var rightSelect = document.getElementById("rightSelect"); //traverse to find the selected option for(var i=0; i

< options.length; i++){ var option1 = options[i]; if(option1.selected){ // 2. 将选中的元素添加到右边的Select中就可以 rightSelect.appendChild(option1); } } } //将左边所有的商品移动到右边 function selectAll(){// 1. 获取左边Select中被选中的元素 var leftSelect = document.getElementById("leftSelect"); var options = leftSelect.options; //找到右侧的Select var rightSelect = document.getElementById("rightSelect"); //遍历找出被选中的option for(var i=options.length - 1; i >

=0; i--){ var option1 = options[i]; rightSelect.appendChild(option1); } } classification name virtools categorized Category Products existing goods >>

Tags: Goods articles categories menus more good practical elements content right name Xiaomi mobile phones articles knowledge Apple Hammer Samsung Huawei Taikang Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple macOS Huawei OPPO Reno