小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

insertAdjacentHTML方法示例

 獨(dú)孤求財(cái) 2012-11-02

添加HTML內(nèi)容與文本內(nèi)容以前用的是innerHTML與innerText方法,最近發(fā)現(xiàn)還有insertAdjacentHTML和insertAdjacentText方法,這兩個(gè)方法更靈活,可以在指定的地方插入html內(nèi)容和文本內(nèi)容。
insertAdjacentHTML方法:在指定的地方插入html標(biāo)簽語(yǔ)句

原型:insertAdajcentHTML(swhere,stext)

參數(shù):

swhere: 指定插入html標(biāo)簽語(yǔ)句的地方,有四種值可用:

1.     beforeBegin: 插入到標(biāo)簽開(kāi)始前

2.     afterBegin:插入到標(biāo)簽開(kāi)始標(biāo)記之后

3.     beforeEnd:插入到標(biāo)簽結(jié)束標(biāo)記前

4.     afterEnd:插入到標(biāo)簽結(jié)束標(biāo)記后

stext:要插入的內(nèi)容

 1 <html>
 2     <head>
 3     <script language="javascript">
 4     function myfun(){
 5         var obj = document.getElementById("btn1");
 6         obj.insertAdjacentHTML("afterEnd","<br><input name="txt1">");
 7     }
 8     </script>
 9     </head>
10     <body>
11         <input name="txt">
12         <input id="btn1" name="btn1" type="button" value="更多" onclick="myfun()">
13     </body>
14 </html>
************************************************************************************

 1 <html>
 2 <head>
 3 <title>24.htm insertAdjacentHTML插入新內(nèi)容</title>
 4 <script language="jscript">
 5 function addsome()
 6 {
 7     document.all.paral.insertAdjacentHTML("afterBegin","<h1>在文本前容器內(nèi)插入內(nèi)容</h1>");
 8     document.all.paral.insertAdjacentHTML("beforeEnd","<h2>在文本后容器內(nèi)插入內(nèi)容</h2>");
 9     document.all.paral.insertAdjacentHTML("beforeBegin","<h4>在文本前容器外插入內(nèi)容</h1>");
10     document.all.paral.insertAdjacentHTML("afterEnd","<h5>在文本后容器外插入內(nèi)容</h2>");
11 }
12 </script>
13 </head>
14 <body onload="addsome()">
15 <div id="paral" style="fontsize:6;color='#ff00ff'">原來(lái)的內(nèi)容</div><hr>
16 </body>
17 </html> 

**********************************************************************************
 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 2 <HTML>
 3 <HEAD>
 4 <TITLE> New Document </TITLE>
 5 <META NAME="Generator" CONTENT="EditPlus">
 6 <META NAME="Author" CONTENT="">
 7 <META NAME="Keywords" CONTENT="">
 8 <META NAME="Description" CONTENT="">
 9 </HEAD>
10 <BODY>
11 <script>
12 var num=0;
13 var No_sys=0;
14 function Add_button(){
15 if(No_sys<8){
16     c_input.insertAdjacentHTML("beforeEnd","<div id="bar"+num+"" oncontextmenu="Remove_button(bar"+num+");return    false" style="background:red;width:40;height:20">"+num+"</div>");
17     num++;
18     No_sys++;
19 }
20 }
21 function Remove_button(obj){
22 obj.removeNode(true);
23 No_sys--;
24 }
25 </script>
26 <input type="button" onclick="Add_button()" value="動(dòng)態(tài)加">
27 <input type="button" onclick="alert(c_input.innerHTML)" value="看">
28 <div id="c_input">
29 </div>  
30 </BODY>
31 </HTML>
posted on 2007-08-30 17:19 Scott.Pan 閱讀(11691) 評(píng)論(1)  編輯  收藏 所屬分類(lèi): 代碼

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀(guān)點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多