首页 > 移动平台 > 详细

移动option

时间:2016-07-24 22:37:03      阅读:326      评论:0      收藏:0      [点我收藏+]
(function() {
var leftSelectObj = document.getElementById(‘leftSelect‘);
var leftBtnUp = document.getElementById(‘left_btn_up‘);
var leftBtnDown = document.getElementById(‘left_btn_down‘);
var rightSelectObj = document.getElementById(‘rightSelect‘);
var rightBtnUp = document.getElementById(‘right_btn_up‘);
var rightBtnDown = document.getElementById(‘right_btn_down‘);
var btnLeft = document.getElementById(‘btn_left‘);
var btnLeftAll = document.getElementById(‘btn_left_all‘);
var btnRight = document.getElementById(‘btn_right‘);
var btnRightAll = document.getElementById(‘btn_right_all‘);

leftBtnDown.onclick = function() {
var index = leftSelectObj.selectedIndex;
if(index !== -1) {
if(index === leftSelectObj.length - 1) {
leftSelectObj.insertBefore(leftSelectObj.children[index], leftSelectObj.children[0]);
} else {
leftSelectObj.insertBefore(leftSelectObj.children[index], leftSelectObj.children[index + 2]);
}
}
};

leftBtnUp.onclick = function() {
var index = leftSelectObj.selectedIndex;
if(index !== -1) {
if(index === 0) {
leftSelectObj.appendChild(leftSelectObj.children[index]);
} else {
leftSelectObj.insertBefore(leftSelectObj.children[index], leftSelectObj.children[index - 1]);
}
}
};

btnRight.onclick = function() {
var index = leftSelectObj.selectedIndex;
if(index !== -1) {
rightSelectObj.appendChild(leftSelectObj.children[index]);
}
};

btnRightAll.onclick = function() {
for(var i = 0; i < leftSelectObj.length; ++i) {
rightSelectObj.appendChild(leftSelectObj.children[i]);
--i;
}
};
})();

移动option

原文:http://www.cnblogs.com/wangchen623/p/5701701.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!