摘要:JS简单小应用之暴力添加节点(代码实例)空空如也:多了春夏秋冬:<"https://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4NCjxwPjxpbWcgYWx0PQ=="这里写图片描述" src="https://www.2cto.com/uploadfile/Collfiles/20180517/2018051710175169.png" title="" />

小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

JS简单小应用之暴力添加节点(代码实例)

 <!DOCTYPE html> <html lang="en">     <head>         <meta charset="utf-8">     </head>     <body>         <input type="button" value="添加春夏秋" onclick="add3()" />         <input type="button" value="添加冬" onclick="add1()" />         <ul></ul>     </body>     <script>     function add3() {         var ul = document.getElementsByTagName('ul')[0];         ul.innerHTML = '<li>春</li><li>夏</li><li>秋</li>';     }      function add1() {         var ul = document.getElementsByTagName('ul')[0];         //alert(ul.innerHTML);         ul.innerHTML += '<li>冬</li>';     }     </script> </html>

空空如也:

多了春夏秋冬:<"https://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4NCjxwPjxpbWcgYWx0PQ=="这里写图片描述" src="https://www.2cto.com/uploadfile/Collfiles/20180517/2018051710175169.png" title="" />

JS简单小应用之暴力添加节点(代码实例)

 <!DOCTYPE html> <html lang="en">     <head>         <meta charset="utf-8">     </head>     <body>         <input type="button" value="添加春夏秋" onclick="add3()" />         <input type="button" value="添加冬" onclick="add1()" />         <ul></ul>     </body>     <script>     function add3() {         var ul = document.getElementsByTagName('ul')[0];         ul.innerHTML = '<li>春</li><li>夏</li><li>秋</li>';     }      function add1() {         var ul = document.getElementsByTagName('ul')[0];         //alert(ul.innerHTML);         ul.innerHTML += '<li>冬</li>';     }     </script> </html>

空空如也:

多了春夏秋冬:<"https://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4NCjxwPjxpbWcgYWx0PQ=="这里写图片描述" src="https://www.2cto.com/uploadfile/Collfiles/20180517/2018051710175169.png" title="" />

觉得可用,就经常来吧!Javascript技巧 脚本宝典 欢迎评论哦! js技巧,巧夺天工,精雕玉琢。小宝典献丑了!

本文固定链接: http://www.js-code.com/js/js_1382.html