zoukankan      html  css  js  c++  java
  • JS DOM编程艺术——显示文献来源链接表—— JS学习笔记2015-7-17(第86天)

    function displayCitations(){
      // 取得所有引用
         var quotes = document.getElementsByTagName("blockquote");
         //遍历引用
         for( var i=0; i<quotes.length; i++){
    
             // 如果没有cite属性,继续循环
             if(!quotes[i].getAttribute("cite")) continue;
             // 保存cite属性
             var url = quotes[i].getAttribute("cite");
             // 取得引用中所有的元素节点
             var quoteChildren = quotes[i].getElementsByTagName("*");
             // 如果没有元素节点,继续循环
             if( quoteChildren.length < 1) continue;
             // 取得引用中的最后一个元素节点
             var elem = quoteChildren[quoteChildren.length-1];
             // 创建标记
             var link = document.createElement("a");
             var link_text = document.createTextNode("source");
             link.appendChild(link_text);
             var superscript = document.createElement("sup");
             superscript.appendChild(link);
             // 把标记添加到引用中的最后一个元素节点;
             elem.appendChild(superscript);
         }
    
     }
     
     addLoadEvent(displayCitations);
  • 相关阅读:
    ACM HDU 1176 免费馅饼(DP)
    PHP下载时中文文件名乱码的问题
    NYOJ 27
    NYOJ 148
    NYOJ 8
    NYOJ 138
    NYOJ 461
    POJ 1200
    STL排序算法
    NYOJ 523
  • 原文地址:https://www.cnblogs.com/zhangxg/p/4655855.html
Copyright © 2011-2022 走看看