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);
  • 相关阅读:
    make ubuntu desktop beautiful
    scratch 编程第二弹
    stratch pragramming
    emacs 安装与基本设置-1
    linux相关命令
    7-12
    python strip()
    python 正则表达式 re.sub & re.subn
    python 正则表达式 re.findall &re.finditer
    python 正则表达式 re.split
  • 原文地址:https://www.cnblogs.com/zhangxg/p/4655855.html
Copyright © 2011-2022 走看看