zoukankan      html  css  js  c++  java
  • Create elements

    create element1:

        var anchorText=document.createTextNode("monoceros");
        var newAnchor = document.createElement("a");
        newAnchor.href="http://www.baidu.com";//给新建的超链接节点添加链接属性
        newAnchor.appendChild(anchorText);
        var parent=document.getElementById("starLinks");
        var newChild=parent.appendChild(newAnchor);
        
        <h1>Creating elements and test nodes</h1>
        <p id="starLinks">
            <a href="test1.htm">Sirius</a>       
        </p>


    create element2:
        var anchorText=document.createTextNode("monoceros");
        var newAnchor = document.createElement("a");
        newAnchor.href = "http://www.baidu.com";
        newAnchor.appendChild(anchorText);
        var existingAnchor=document.getElementById("sirius");
        var parent=existingAnchor.parentNode;
        var newChild=parent.insertBefore(newAnchor,existingAnchor);

        <h1>Creating elements and text nodes</h1>
        <p id="starLinks">
            <a id="sirius" href="test1.htm">Sirius</a>
        </p>

    create element3:
        var anchorText=document.createTextNode("monoceros");
        var newAnchor = document.createElement("a");
        newAnchor.href = "http://www.baidu.com";
        newAnchor.appendChild(anchorText);
        var existingAnchor=document.getElementById("sirius");
        var parent=existingAnchor.parentNode;
        var newChild=parent.replaceChild(newAnchor,existingAnchor);

        <h1>Creating elements and text nodes</h1>
        <p id="starLinks">
            <a id="sirius" href="test1.htm">Sirius</a>
        </p>

  • 相关阅读:
    SpringMVC防止重复提交
    Apache Lucene初探
    ORACLE触发器详解
    ORA-02287: sequence number not allowed here问题的解决
    数据库索引
    字符串 栈
    字符串 逆序
    汽水瓶
    查找 排序----有一只兔子,从出生后第3个月起每个月都生一只兔子,小兔子长到第三个月后每个月又生一只兔子,假如兔子都不死,问每个月的兔子总数为多少?
    usb串口的作用以及JLINK
  • 原文地址:https://www.cnblogs.com/chengpeng/p/2147827.html
Copyright © 2011-2022 走看看