前端开发问题点

1、placeholder="请做自我介绍" 此处没有生效

<textarea cols="20" rows="5" name="txt" placeholder="请做自我介绍">    
<!--placeholder="请做自我介绍" 此处没有生效  -->
</textarea>

 解决</textarea>要紧跟在<textarea>后面 否则中间<textarea></textarea>之间的文字会覆盖掉placeholder的信息,如下:

<textarea cols="20" rows="5" name="txt" placeholder="请做自我介绍"></textarea>

 2、为什么第一次点击超链接的样式后会变成绿色,但刷新后却不会变回来?

/*单机访问时超链接的样式*/
a:visited{
            color:green;
        }

 3.第二种是什么意思?

4.在script标签下 ,如注释所说:为何此处打印的为啥都是3?

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Title</title>
 6     <style type="text/css">
 7     *{
 8         padding: 0;
 9         margin: 0;
10     }
11     ul{list-style: none}
12     #tab{
13          480px;
14         margin:20px auto ;
15         border: 1px solid red;
16     }
17     ul li{
18         float: left;
19          160px;
20         height: 60px;
21         line-height: 60px;
22         text-align: center;
23         background: #cccccc;
24     }
25     ul li a{
26         text-decoration: none;
27         color: black;
28     }
29     li.active{
30         background-color: #ffffff;
31     }
32     p{
33         display: none;
34         height: 200px;
35         text-align: center;
36         line-height: 200px;
37         background-color: #ffffff;
38     }
39     p.active{
40         display: block;
41     }
42 
43     </style>
44 </head>
45 <body>
46     <div id="tab">
47         <ul>
48             <li class="active"><a href="#">首页</a></li>
49             <li><a href="#">新闻</a></li>
50             <li><a href="#">图片</a></li>
51         </ul>
52         <p class="active">首页内容</p>
53         <p>新闻内容</p>
54         <p>图片内容</p>
55     </div>
56 
57 </body>
58 
59 <script type="text/javascript">
60     var tabli=document.getElementsByTagName('li')
61 
62     var tabContent = document.getElementsByTagName('p')
63 
64     for(var i=0;i<tabli.length;i++){
65         console.log(tabli[i])
66         tabli[i].index = i;
67         tabli[i].onclick = function () {
68             console.log(i) //此处打印的为啥都是3?
69             for(var j= 0;j<tabli.length;j++){
70                 tabli[j].className = '';
71                 tabContent[j].className='';
72             }
73 
74             this.className = 'active'
75             console.log(i);
76             tabContent[this.index].className = 'active'
77             // console.log(i)
78         }
79 
80     }
81 </script>
82 </html>
View Code

答案参考https://www.cnblogs.com/pssp/p/5215417.html

5. 在 匀速运动案例中,

为何此处要在前面先声明time变量才能在函数btn.onclick中用于被赋值?
 1  var time =null;
 2     btn.onclick = function () {
 3         time = setInterval(function () { //为何此处要在前面先声明time变量才能在此处用于赋值
 4             count++;
 5             if (count>1000) {
 6                 clearInterval(time);
 7                 box1.style.display = 'none'
 8             }
 9             box1.style.left = count+'px'
10 
11         },10)
原文地址:https://www.cnblogs.com/lukechenblogs/p/8974233.html