久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      JavaScript在頁面增加元素

      方法:1、使用“getElementsByTagName()”獲取父節(jié)點元素;2、使用“createElement()”動態(tài)創(chuàng)建標簽;3、使用“appendChild()”將標簽放在指定元素下;4、使用“innerHTML”添加文本內(nèi)容。

      JavaScript在頁面增加元素

      本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。

      想要在頁面動態(tài)添加元素,首先要確定在哪個元素后面添加元素,然后利用js的appendChild方法在該元素后面追加元素。

      1.獲取父節(jié)點元素var body = document.getElementsByTagName('body')[0]。

      2.然后動態(tài)創(chuàng)建a標簽var a = document.createElement('a')。

      3.把創(chuàng)建好的a標簽追加到body下面body.appendChild(a)。

      4.在a標簽里面添加文本內(nèi)容a.innerHTML = '這是一個鏈接'。給a標簽添加一個鏈接a.href = 'https://www.baidu.com/'。

      JavaScript在頁面增加元素

      擴展資料:

      js一些原生方法

      • element.appendChild()方法向節(jié)點添加最后一個子節(jié)點。

      • element.innerHTML設置或返回元素的內(nèi)容。

      • document.getElementsByTagName()返回帶有指定標簽名的對象集合。

      • document.getElementById()返回對擁有指定 id 的第一個對象的引用。

      • document.createElement()通過指定名稱創(chuàng)建一個元素。

      【推薦學習:javascript高級教程】

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號