码迷,mamicode.com
首页 > 其他好文 > 详细

for循环

时间:2018-11-11 15:06:34      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:bsp   rip   utf-8   esc   for循环   dem   get   document   demo   

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">点击这里</button>
<p id="demo"></p>

<script>
function myFunction()
{
var x;
var txt="";
var person={fname:"dave",lname:"Gates",age:15};

for (x in person)
{
txt=txt + person[x];
}

document.getElementById("demo").innerHTML=txt;
}
</script>
</body>
</html>

 

 

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script>
var myArry =[1,2,3,4];
myArry.desc =‘four‘;
for(var value of myArry){
  console.log(value)
}
document.write(myArry);
        </script>
    </head>
    <body>
    </body>
</html>

 

 

<!DOCTYPE html>
<html>
    <head> <meta charset="UTF-8" />
        <title>Document</title>
    </head> <body>
        <script>
        var arr = [1,2,3,4,5];
        arr.forEach(function(e)
        {
           document.write(e);
        })
    </script>
</body>
</html>

for循环

标签:bsp   rip   utf-8   esc   for循环   dem   get   document   demo   

原文地址:https://www.cnblogs.com/ghostandgod/p/9941967.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!