| 类别: | Javascript, function |
|---|---|
| 标签: | js, func, append, node, Element, container, fAppendNodeFirst, append_node_at_first_f |
| 摘要: | .. |
| 正文: |
2008 年 09 月 12 日, 10 时 44 分 00 秒 936 毫秒 <script type="text/javascript"> /*<![CDATA[*/ /* 版本:2008-9-12 作用:把某节点添加到指定容器的首位置 必填参数:container_e, append_e */ function append_node_at_first_f(container_e, append_e) {/* shawl.qiu code return default, func:none */ if(container_e.childNodes.length===0) return container_e.appendChild(append_e); return container_e.insertBefore(append_e, container_e.firstChild); }/* function append_node_at_first_f(container_e, append_e) */ /*]]>*/ </script> 2008 年 06 月 02 日, 09 时 46 分 38 秒 937 毫秒 function fAppendNodeFirst(ContainerElement, ForAppendElement) {/* shawl.qiu code return default */ if(ContainerElement.childNodes.length===0) return ContainerElement.appendChild(ForAppendElement); return ContainerElement.insertBefore(ForAppendElement, ContainerElement.firstChild); }/* function fAppendNodeFirst(ContainerElement, ForAppendElement) */ <div id="id"> </div> <script type="text/javascript"> //<![CDATA[ var Div = document.getElementById("id"); var Div1 = document.createElement("div") Div1.innerHTML = "ok"; fAppendNodeFirst(Div, Div1); function fAppendNodeFirst(ContainerElement, ForAppendElement) {// shawl.qiu code : void return if(ContainerElement.childNodes.length===0) { ContainerElement.appendChild(ForAppendElement); return; } ContainerElement.insertBefore(ForAppendElement, ContainerElement.firstChild); } // end function fAppendNodeFirst(ContainerElement, ForAppendElement) //]]> </script>
|
| 文章相关信息: | |
|---|---|
| 主题: | js 添加节点到容器的第一项函数 fAppendNodeFirst |
| 发表者: | shawl.qiu |
| 电子邮件: | shawl.qiu@gmail.com |
| QQ: | 908202921 |
| MSN: | btbtd@msn.com |
| Homepage: | http://www.btbtd.org/ |
| Blog: | http://blog.csdn.net/btbtd/ |
| 发表日期: | 2007-7-31 12:00:35 |
| 更新日期: | 2008-9-12 10:44:21 |
| 来源引用: | shawl.qiu CSharp DotNet 个人资料管理系统 |
| 引用本页: | http://gi.2288.org/mod/code/display/Default.aspx?aid=508 |