国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

總結(jié)AJAX相關(guān)JS代碼片段和瀏覽器模型

2019-11-21 01:58:18
字體:
供稿:網(wǎng)友
在.net開發(fā)中,充分利用免費控件是好事情,但是如果不能修改控件達(dá)到自己的需求,就要動用JS大法了,前提是研究好瀏覽器模型 的各種對象的方法屬性。尤其是熟悉CSS+HTML就會做的很酷。就JS語言本身來說要求不高。

  1、動態(tài)刪除Table 里面內(nèi)容技巧,不需要寫太多代碼,一行:

tb.removeNode(true) 

  2、動態(tài)增加行,除了CreateElement方法,還可以這樣比較短小:

<table id=tb1></table>
<SCRIPT>
function addTable(){
 var row1 = tb1.insertRow(); 
 var cell1=row1.insertCell();
 var cell2=row1.insertCell();
 cell1.innerText="灰豆寶寶";
 cell2.innerText="超級大笨狼"
}
</SCRIPT> 
<INPUT TYPE = "button" VALUE = "AddTable" onclick = "addTable()"> 

  3、在DIV中動態(tài)增加Table

<SCRIPT>
function addTable(){
 var tb1 = document.createElement("table";
 tb1.border="1px";
 var row1 = tb1.insertRow(); 
 var cell1=row1.insertCell();
 var cell2=row1.insertCell();
 mydiv.appendChild(tb1);
 cell1.innerText="wanghr100";
 cell2.innerText="panyuguang962"
}
</SCRIPT>
<BODY>
<div id=mydiv style="width:400;height:300;"></div>
<INPUT TYPE = "button" VALUE = "AddTable" onclick = "addTable()"> 

  4、在DIV中刪除Table,簡單只要Div.innerHTML=""就可以。

  以上是部分實用相對短小的代碼,當(dāng)然有其他各種辦法實現(xiàn),不過一般都比上面的長,比如組合使用DIV對象的insertAdjacentHTML 方法等,在不同需要下使用不同方法,前提是研究好瀏覽器模型 的各種對象的方法屬性。尤其是熟悉CSS+HTML就會做的很酷。就JS語言本身來說要求不高。

  以下是以Document對象為例,相關(guān)方法有:

Method Description 
attachEvent 
createAttribute 
createComment 
createDocumentFragment 
createElement 
createEventObject 
createStyleSheet 
createTextNode 
detachEvent 
getElementById 
getElementsByName 
getElementsByTagName 
mergeAttributes
recalc 
write 
writeln 

  以DIV對象為例相關(guān)方法有:

addBehavior 
appendChild 
applyElement 
attachEvent 
clearAttributes
cloneNode 
contains 
detachEvent
getAdjacentText 
getAttribute 
getAttributeNode 
getElementsByTagName 
hasChildNodes 
insertAdjacentElement 
insertAdjacentHTML 
insertAdjacentText 
insertBefore
mergeAttributes 
normalize
removeAttribute 
removeAttributeNode 
removeBehavior 
removeChild 
removeExpression 
removeNode 
replaceAdjacentText 
replaceChild 
replaceNode 
setActive 
setAttribute 
setAttributeNode 
setExpression 
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 息烽县| 宁乡县| 上饶县| 嘉义县| 航空| 淄博市| 原平市| 九寨沟县| 水城县| 阿拉善左旗| 屯门区| 兰考县| 乾安县| 南澳县| 临沂市| 固始县| 嘉黎县| 神农架林区| 辽宁省| 灵台县| 巴楚县| 沾益县| 新竹县| 乐安县| 建宁县| 哈巴河县| 旬阳县| 安顺市| 岳阳市| 唐海县| 英德市| 左云县| 华宁县| 赤水市| 会理县| 罗定市| 鄱阳县| 沙田区| 资阳市| 衡东县| 五大连池市|