javascript进阶一

一 window对象

  http://www.w3school.com.cn/jsref/dom_obj_window.asp

二 setInterval的应用

  模拟计时器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function foo() {
            var current_time=(new Date()).toLocaleString()
            var ele_input=document.getElementById('d1')
            ele_input.value=current_time
        }

        var ID;
        function begining() {
            if(ID==undefined){
                  foo()
                  ID=setInterval(foo,1000)
            }
        }
        function ending() {
            console.log('clear之前ID',ID)
            clearInterval(ID)
            console.log('clear之后ID',ID)
            ID=undefined
        }
    </script>
</head>
<body>
<input type="text" id="d1"><button onclick="begining()">begin</button><button onclick="ending()">ending</button>
</body>
</html>

  输出:

  

 

三  value固有属性的三个标签

  input标签

  textarea标签

  select下的option标签

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <from>
        <input type="text" value="1">
        <textarea name="" cols="30" rows="10" ></textarea>
        <select name="" id="">
            <option value=""></option>
        </select>
    </from>
</body>
</html>

 

posted @ 2017-11-09 17:34  骑者赶路  阅读(100)  评论(0编辑  收藏  举报