选项卡 tab切换

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div>
        <input type="button" value='red'>
        <input type="button" value='green'>
        <input type="button" value='blue'>
        <input type="button" value='purple'>
        <input type="button" value='pink'>
        <div style='200px;height:200px;'></div>
    </div>
    <script>
    /*
        选项卡 tab切换 
    */
        var Chef = {
            input:document.getElementsByTagName('input'),
            div:document.getElementsByTagName('div')[1],
            inputEvent:function(){
                for(var i = 0;i<this.input.length;i++){
                    this.input[i].onclick = function(){
                        Chef.div.style.background = this.value;
                    }
                }
            }
        }
        Chef.inputEvent();
    </script>
</body>
</html>
原文地址:https://www.cnblogs.com/chefweb/p/5956430.html