(自己)

作者: 行之北斗 | 来源:发表于2019-03-27 16:54 被阅读0次

setTimeout setInterval()延迟几秒

//执行一次
setTimeout('alert("hello")',3000);
//不停地执行
setInterval('alert("hello")',3000);

window.onload()方法:

该方法用于在网页加载完毕后立刻执行的操作,即当html加载完毕后,立刻执行某个方法等。

window.onload = function(){
                var num = document.getElementById("t").value;
                setTimeout(go(),num);
            }

window.location 用于网页跳转

window.location.href="https://www.baidu.com";
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script type="text/javascript">
            function cj(){
                //获取id为table的对象
                var table = document.getElementById("mytable");
                
                
                
                for(var i =0 ;i<10;i++){
                    //创建<tr></tr>
                    var tr = document.createElement("tr");
                    if(i%2==0){
                        tr.style.backgroundColor = "red";
                    }
                    //创建<td></td>
                    var td = document.createElement("td");
                    //将td放到tr中
                    tr.appendChild(td);
                    //td中的内容
                    td.innerText = "line"+i;
                    //将tr放到table中
                    table.appendChild(tr);
                    
                    
                }
                
            }
        </script>
    </head>
    <body>
        <table id="mytable">
            
            
        </table>
        <input type="button" value="创建" id="ccjj" onclick="cj();"/>
    </body>
</html>

相关文章

网友评论

      本文标题:(自己)

      本文链接:https://www.haomeiwen.com/subject/ujqtbqtx.html