zoukankan      html  css  js  c++  java
  • 定义一个函数,创建HTML列表(arguments)

     1 function list(type) {
     2             var result = "<" + type + ">";
     3 
     4             // iterate through non-type arguments
     5             for (var i = 1; i < arguments.length; i++) {
     6                 result += "<li>" + arguments[i] + "</li>";
     7             }
     8 
     9             result += "</" + type + ">"; // end list
    10 
    11             return result;
    12         }
    13         var listHTML = list("ul", "One", "Two", "Three");
    14         // listHTML is "<ul><li>One</li><li>Two</li><li>Three</li></ul>"
    15         console.log(listHTML);

    You can pass any number of arguments to this function

  • 相关阅读:
    UVA 1001 Say Cheese
    UVa 821 Page Hopping
    UVA 1569 Multiple
    UVA 1395 Slim Span
    UVA 12219 Common Subexpression Elimination
    UVA 246 10-20-30
    Mysql基本操作
    浅析关键字static
    面试回答技巧
    五个程序员好习惯
  • 原文地址:https://www.cnblogs.com/qzsonline/p/2393309.html
Copyright © 2011-2022 走看看