码迷,mamicode.com
首页 > 移动开发 > 详细

移动option

时间:2016-07-24 22:37:55      阅读:225      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!