jquery穿梭框

<style>

li {

        list-style: none;

        width: 100%;

        height: 20px;

        background-color: #999;

    }

    .Path {

        color: #ffffff !important;

        background-color: #1890ff !important;

        border-bottom: 1px solid #ffffff;

        transition: all .01s;

    }

    .leftBox {

        display: inline-block;

        width: 200px;

        height: 300px;

        background-color: #ddd;

        vertical-align: top;

    }

    .rightBox {

        display: inline-block;

        width: 200px;

        height: 300px;

        background-color: #ddd;

        vertical-align: top;

    }

    .btnBox {

        display: inline-block;

        vertical-align: top;

    }

    .btnBox button {

        display: block;

        background-color: orangered;

        width: 100px;

        height: 40px;

        margin-top: 30px;

    }

</style>

<body>

    <ul class="leftBox">

        <li>左1</li>

        <li>左2</li>

        <li>左3</li>

    </ul>

    <div class="btnBox">

        <button class="leftBtn"><-</button>

        <button class="rightBtn">-></button>

    </div>

    <ul class="rightBox">

        <li>右1</li>

        <li>右2</li>

        <li>右3</li>

    </ul>

    <script>

    </script>

</body>

<script>

//穿梭框左侧选中

$(".leftBox").on('click', 'li', function() {

    if ($(this).hasClass('Path')) {

        $(this).removeClass('Path');

    } else {

        $(this).addClass('Path');

    }

});

//穿梭框右侧选中

$(".rightBox").on('click', 'li', function() {

    if ($(this).hasClass('Path')) {

        $(this).removeClass('Path');

    } else {

        $(this).addClass('Path');

    }

});

//向右移动

$(".rightBtn").click(function() {

    if ($(".leftBox .Path").length == 0) return false;

    $(".leftBox").find('.Path').appendTo(".rightBox");

    $(".rightBox li").removeClass('Path');

});

//向左移动

$(".leftBtn").click(function() {

    if ($(".rightBox .Path").length == 0) return false;

    $(".rightBox .Path").appendTo(".leftBox");

    $(".leftBox li").removeClass('Path');

});

</script>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1. tab列表折叠效果 html: 能源系统事业部 岗位名称: 工作地点 岗位名...
    lilyping阅读 5,875评论 0 1
  • "use strict";function _classCallCheck(e,t){if(!(e instanc...
    久些阅读 6,133评论 0 2
  • 不会用代码框,所以看着有些乱套,,,,html部分 <!DOCTYPE html> 迅雷看看 ...
    这就是个帅气的名字阅读 5,438评论 0 0
  • 从心理学、市场营销学和医药学等方面的研究来看,我们个人的选择在很大程度上会受他人想法、意愿和行为的影响。 通过一段...
    snailwww阅读 1,313评论 0 2
  • 我们去操场和妈妈去阅读了,在读完之后呢,我就让我的妈妈走了!。我们语文学的一 二 三。数学我们练习的是一 二 三,...
    魏路德阅读 1,664评论 1 0