JavaScript小练习

简介: JavaScript小练习

<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-">
     <meta name="viewport" content="width=device-width, initial-scale=.">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>Document</title>
     <style type="text/css">
         .set_bg_con{
            width:px;
            height:px;
            border:px solid #ddd;
            margin:px auto ;
            background-color:#fff
        }
        .set_text{
            line-height:px;
            float:left;
            margin: px  px;
            color:#;
        }
        .style,.style,.style,.style,.style,.style{
            width:px;
            height:px;
            float:left;
            margin:px px;
            background: gold;
            cursor:pointer;
        }
        .style{
            background:#cc;
        }
        .style{
            background:#bf;
        }
        .style{
            background:#ef;
        }
        .style{
            background:#fc;
        }
        .style{
            background:#e;
        }
        .style{
            background:#eeb;
        }
    </style>
    <script type="text/javascript">
        window.onload = function(){
            var oBtn = document.getElementById('c');
            var oBtn = document.getElementById('c');
            var oBtn = document.getElementById('c');
            var oBtn = document.getElementById('c');
            var oBtn = document.getElementById('c');
            var oBtn = document.getElementById('c');
            var oBody = document.getElementById('body')
            oBtn.onclick = function(){
                oBody.style.backgroundColor = '#cc';
            }
            oBtn.onclick = function(){
                oBody.style.backgroundColor = '#bf';
            }
            oBtn.onclick = function(){
                oBody.style.backgroundColor = '#ef';
            }
            oBtn.onclick = function(){
                oBody.style.backgroundColor = '#fc';
            }
            oBtn.onclick = function(){
                oBody.style.backgroundColor = '#e';
            }
            oBtn.onclick = function(){
                oBody.style.backgroundColor = '#eeb';
            }
        }
    </script>
</head>
<body id="body">
    <div class="set_bg_con">
        <div class="set_text">请选择网页的背景色:</div>
        <div class="style" id="c"></div>
        <div class="style" id="c"></div>
        <div class="style" id="c"></div>
        <div class="style" id="c"></div>
        <div class="style" id="c"></div>
        <div class="style" id="c"></div>
    </div>
</body>
</html>


<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-">
     <meta name="viewport" content="width=device-width, initial-scale=.">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>Document</title>
     <style type="text/css">
         .set_con{
            width:px;
            height:px;
            border:px solid #;
            margin:px auto ;
        }
        .left_set{
            width:px;
            float:left;
            height:px;
            border-right:px solid #;
            padding-top:px;
        }
        .left_set label{
            float:left;
            width:px;
            height:px;
            line-height:px;
            text-align:left;
            text-indent:px;
            margin-top:px;
            font-size:px;
        }
        .left_set input{
            padding:px;
            width:px;
            height:px;
            border: px solid #;
            float:left;
            margin-top:px;
            text-indent:px;
            outline:none;
        }
        .left_set .setbtn{
            width:px;
            height:px;
            border:px;
            background:#cc;
            color:#fff;
            text-indent:px;
            margin-left:px;
            font-size:px;
            margin-top:px
        }
        .right_show{
            width:px;
            height:px;
            float:left;
            overflow:auto;
        }
        .box{
            width:px;
            height:px;
            border: px solid #;
            background:gold;
            margin:px auto ;
        }
    </style>
    <script type="text/javascript">      
       window.onload = function(){
            var oInput = document.getElementById('input');
            var oInput = document.getElementById('input');
            var oInput = document.getElementById('input');
            var oInput = document.getElementById('input');
            var oInput = document.getElementById('input');
            var oBtn = document.getElementById('input');
            var oBox = document.getElementById('box');
            oBtn.onclick = function(){
                var sVal = oInput.value;
                var sVal = oInput.value;
                var sVal = oInput.value;
                var sVal = oInput.value;
                var sVal = oInput.value;
                oBox.style.width = sVal;
                oBox.style.height = sVal;
                oBox.style.backgroundColor = sVal;
                oBox.style.border = sVal;
                oBox.style.borderRadius = sVal;
            }
       }
    </script>
</head>
<body>
    <div class="set_con">
        <div class="left_set">
            <label>宽度:</label>
            <input type="text" value="px" id="input">
            <label>高度:</label>
            <input type="text" value="px" id="input">
            <label>背景色:</label>
            <input type="text" value="gold" id="input">
            <label>边框:</label>
            <input type="text" value="px solid #" id="input">
            <label>圆角:</label>
            <input type="text" value="px"  id="input">
            <input type="button" value="设 置" class="setbtn" id="input">
        </div>
        <div class="right_show">
            <div class="box" id="box"></div>
        </div>
    </div>
</body>
</html>
相关文章
|
3月前
|
存储 JavaScript 前端开发
JS项目练习
JS项目练习
|
2月前
|
移动开发 前端开发 JavaScript
H5+CSS3+JS逆向前置——4、DIV+CSS绘制旗帜练习
H5+CSS3+JS逆向前置——4、DIV+CSS绘制旗帜练习
21 0
|
3月前
|
存储 JavaScript
JS中相等(==)和等全(===)的区别与练习
JS中相等(==)和等全(===)的区别与练习
21 1
|
5月前
|
JavaScript
js对象案例练习
js对象案例练习
37 0
|
6月前
|
JavaScript 前端开发
带你读《现代Javascript高级教程》二十四、正则表达式的常见问题与练习(1)
带你读《现代Javascript高级教程》二十四、正则表达式的常见问题与练习(1)
|
6月前
|
JavaScript 前端开发
带你读《现代Javascript高级教程》二十四、正则表达式的常见问题与练习(2)
带你读《现代Javascript高级教程》二十四、正则表达式的常见问题与练习(2)
|
7月前
|
JavaScript 前端开发
JavaScript小练习
JavaScript小练习
|
8月前
|
JavaScript 前端开发
Javascript数组编程练习
Javascript数组编程练习
58 2
|
9月前
|
XML JSON JavaScript
在JavaScript中用json对象创建一个table表格——实战练习
在JavaScript中用json对象创建一个table表格——实战练习
184 0
|
9月前
|
JavaScript 前端开发
《现代Javascript高级教程》正则表达式的常见问题与练习
正则表达式的常见问题与练习 正则表达式是面试中经常被提及的主题之一,但很多人在面试中对于正则表达式的问题常常感到困惑。在本节中,我将通过一些常见问题和练习题目来帮助你更好地理解和掌握正则表达式的技巧。
41 0