Js中水果选择特效制作

    <style>
        select{
            width: 100px;
        }
    </style>
</head>
<body>
<form action="" class="form">
    <select name="" id="s1" size="10">
        <option value="苹果">苹果</option>
        <option value="香蕉">香蕉</option>
        <option value="金桔">金桔</option>
        <option value="西瓜">西瓜</option>
        <option value="菠萝">菠萝</option>
        <option value="柿子">柿子</option>
        <option value=“哈密瓜">哈密瓜</option>
        <option value="葡萄">葡萄</option>
    </select>
    <button id="bid">&raquo;</button>
    <select name="" id="s2" size="10">

    </select>
</form>
<script>
    var bid=document.getElementById("bid");
    bid.onclick=function () {
        var s1=document.getElementById("s1");
        var s2=document.getElementById("s2");
        var index=s1.selectedIndex;
        if(index >= 0){
            s2.add(s1.options[index]);
        }
    }
</script>

猜你喜欢

转载自blog.csdn.net/weixin_44022886/article/details/84995280