道非道 非常道

          勤思、謹言、慎行、厚積、薄發

          統計

          web

          天圓

          經濟 政治 軍事

          鍵康

          [轉] insertAdjacentHTML和insertAdjacentText 方法

                  轉自網絡
             添加HTML內容與文本內容以前用的是innerHTML與innerText方法,最近發覺還有insertAdjacentHTML和insertAdjacentText要領,這兩個要領更靈活,可以在指定的地點插入html內容和文本內容。
          insertAdjacentHTML要領:在指定的地點插入html標簽語句

          原型:insertAdajcentHTML(swhere,stext)

          參數:

          swhere: 指定插入html標簽語句的地點,有四種值可用:

          1.     beforeBegin: 插入到標簽開始前

          2.     afterBegin:插入到標簽開始標記之后

          3.     beforeEnd:插入到標簽結束標記前

          4.     afterEnd:插入到標簽結束標記后

          stext:要插入的內容

           1 
           2 DEOM:
           3 
           4 <html>
           5 
           6    <head>
           7 
           8     <script language="javascript">
           9 
          10        function myfun()
          11 
          12          {
          13 
          14              var obj = document.getElementById("btn1");
          15 
          16               obj.insertAdjacentHTML("afterEnd","<br><input name=\"txt1\">");
          17 
          18          }
          19 
          20       </script>
          21 
          22    </head>
          23 
          24    <body>
          25 
          26      <input name="txt">
          27 
          28      <input id="btn1" name="btn1" type="button" value="更多" onclick="myfun()">
          29 
          30    </body>
          31 
          32 </html>




          posted on 2009-07-31 11:17 星期五 閱讀(126) 評論(0)  編輯  收藏 所屬分類: web 2.0

          主站蜘蛛池模板: 正宁县| 儋州市| 平度市| 孙吴县| 铜陵市| 定边县| 铜山县| 临邑县| 合川市| 黔南| 内丘县| 固阳县| 鸡泽县| 沿河| 兴和县| 伊吾县| 大新县| 长沙市| 池州市| 吴江市| 前郭尔| 麟游县| 闽清县| 略阳县| 宜州市| 绥棱县| 江津市| 朝阳县| 天全县| 巴彦县| 长寿区| 岢岚县| 吉安市| 西安市| 张家口市| 蒙山县| 犍为县| 白水县| 治多县| 同德县| 安塞县|