zoukankan      html  css  js  c++  java
  • 赋值取值+arguments

    等项目上线,写点简单的东西练练手

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
     3 <head>
     4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
     5     <title></title>
     6     <style type="text/css">
     7     p{
     8         width: 20px;
     9         height: 20px;
    10         cursor: pointer;
    11         color: #ffffff;
    12         background: #333333;
    13     }
    14     </style>
    15     <script type="text/javascript" src="index.js"></script>
    16 </head>
    17 <body>
    18     <p class="class1" title="title1">1</p>
    19     <p class="class2" title="title2">2</p>
    20     <p class="class3" title="title3">3</p>
    21     <p class="class4" title="title4">4</p>
    22     <p class="class5" title="title5">5</p>
    23     <br/>
    24     <div id="showValue"></div>
    25     <br/>
    26     <div id="showName"></div>
    27     <br/>
    28     <div id="showClass"></div>
    29     <br/>
    30     <input type="text" id="showInput" />
    31     <br/>
    32     <textarea id="showTextarea"></textarea>
    33 </body>
    34 </html>
     1 (function() {
     2     window.onload = function() {
     3         //取值、赋值
     4         var getP = document.getElementsByTagName('p');
     5         var showValue = document.getElementById('showValue');
     6         var showName = document.getElementById('showName');
     7         var showClass = document.getElementById('showClass');
     8         var showInput = document.getElementById('showInput');
     9         var showTextarea = document.getElementById('showTextarea');
    10         for (var i = 0, len = getP.length; i < len; i++) {
    11             getP[i].onclick = function() {
    12                 showValue.innerHTML = this.innerHTML;
    13                 showName.innerHTML = this.title;
    14                 showClass.innerHTML = this.className;
    15                 showInput.value = this.innerHTML;
    16                 showTextarea.innerHTML = this.innerHTML;
    17             };
    18         }
    19 
    20         //测试arguments
    21         function showMe(message, callback, newCallBack) {
    22             console.log(arguments[0]);
    23             console.log(arguments.length);
    24             for (var i = 0, len = arguments.length; i < len; i++) {
    25                 console.log(arguments[i]);
    26             }
    27         }
    28         showMe("我的参数是message", "我的参数是callback", "我的参数是newCallBack");
    29     };
    30 })();
  • 相关阅读:
    9IDEA常见的快捷键
    8Java类与对象
    5Java运算符
    10Java面向对象中级
    3Java基础
    4Java基础变量
    6Java控制结构
    7Java数组
    11Java面向对象高级
    缓存事件过期监听机制
  • 原文地址:https://www.cnblogs.com/qzsonline/p/2569978.html
Copyright © 2011-2022 走看看