removeChild Method
Removes the specified child node from the list of children and returns it.[Script]
Script Syntax
var objXMLDOMNode = oXMLDOMNode.removeChild(childNode);
Parameters
childNode
An object. Child node to be removed from the list of children of this node.
Return Value
An object. Returns the removed child node.Example
The following script example creates an IXMLDOMNode object (currNode), removes a child node from it, and displays the text of the removed node.var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var root;
var currNode;
var oldChild;
xmlDoc.async = false;
xmlDoc.load("books.xml");
root = xmlDoc.documentElement;
currNode = root.childNodes.item(1);
oldChild = currNode.removeChild(currNode.childNodes.item(1));
alert(oldChild.text);
[Visual Basic]
Visual Basic Syntax
Set objXMLDOMNode = oXMLDOMNode.removeChild(childNode)
Parameters
childNode
An object. The child node to be removed from the list of children of this node.
Return Value
An object. Returns the removed child node.Example
The following Microsoft® Visual Basic® example creates an IXMLDOMNode object (currNode), removes a child node from it, and displays the text of the removed node.Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim currNode As IXMLDOMNode
Dim oldChild As IXMLDOMNode
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
Set currNode = root.childNodes.Item(1)
Set oldChild = currNode.removeChild(currNode.childNodes.Item(1))
MsgBox oldChild.Text
[C/C++]
C/C++ Syntax
HRESULT removeChild(
IXMLDOMNode *childNode,
IXMLDOMNode **outOldChild);
Parameters
childNode [in]
The child node to be removed from the list of children of this node.
outOldChild [out, retval]
The removed child node. If Null, no object is created.
C/C++ Return Values
S_OK
The value returned if successful.
E_INVALIDARG
The value returned if oldChild is not a child of this node, when the specified oldChild is read-only and cannot be removed, or when oldChild is Null.
E_FAIL
The value returned if an error occurs. To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
Removes the specified child node from the list of children and returns it.[Script]
Script Syntax
var objXMLDOMNode = oXMLDOMNode.removeChild(childNode);
Parameters
childNode
An object. Child node to be removed from the list of children of this node.
Return Value
An object. Returns the removed child node.Example
The following script example creates an IXMLDOMNode object (currNode), removes a child node from it, and displays the text of the removed node.var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
var root;
var currNode;
var oldChild;
xmlDoc.async = false;
xmlDoc.load("books.xml");
root = xmlDoc.documentElement;
currNode = root.childNodes.item(1);
oldChild = currNode.removeChild(currNode.childNodes.item(1));
alert(oldChild.text);
[Visual Basic]
Visual Basic Syntax
Set objXMLDOMNode = oXMLDOMNode.removeChild(childNode)
Parameters
childNode
An object. The child node to be removed from the list of children of this node.
Return Value
An object. Returns the removed child node.Example
The following Microsoft® Visual Basic® example creates an IXMLDOMNode object (currNode), removes a child node from it, and displays the text of the removed node.Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim currNode As IXMLDOMNode
Dim oldChild As IXMLDOMNode
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
Set currNode = root.childNodes.Item(1)
Set oldChild = currNode.removeChild(currNode.childNodes.Item(1))
MsgBox oldChild.Text
[C/C++]
C/C++ Syntax
HRESULT removeChild(
IXMLDOMNode *childNode,
IXMLDOMNode **outOldChild);
Parameters
childNode [in]
The child node to be removed from the list of children of this node.
outOldChild [out, retval]
The removed child node. If Null, no object is created.
C/C++ Return Values
S_OK
The value returned if successful.
E_INVALIDARG
The value returned if oldChild is not a child of this node, when the specified oldChild is read-only and cannot be removed, or when oldChild is Null.
E_FAIL
The value returned if an error occurs. To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
解决方案 »
- jqeury height()获取高度自适应div高度问题
- dhtmltree 右键下子菜单跑到父菜单下面去了!!
- 请教,jquery或者js提交表单的问题
- 标签ID相同,值不同!怎么得到不同的值!javascript
- 个人网站,献丑了 http://www.hualine.com/lizheng/index.aspx 需要源代码者请留言。
- 诚聘版主
- 如何在javascript中用submit传递中文的函数
- 如果用JS实现实时编辑效果?
- 请问应如何设置textbox的底色啊
- SOS,关于excel的问题
- 求教关于web窗口最小化和打开自动关闭的奇怪问题
- 怎样把表格中的数据保存到本地的TXT文件?
<td name=1 onmousedown="check(this);">黑色金属 禁用 </td>
<td name=2 onmousedown="check(this);">>橡胶制品 禁用 </td>
<td name=3 onmousedown="check(this);">>油料油脂 禁用 </td>
<td name=4 onmousedown="check(this);">>花轻产品 禁用 </td><input type=hidden name="a"><script>
function check(id){
document.all('a').value=this.name;
}
</script>
左边框架
<input type=button value="删除" onclick="test();"><script>
function test(){
if(self.top.frames['main']).document.all('a').value.length<1{
alert("请选择要删除的目录");
}else{
var name=self.top.frames['main']).document.all('a').value;
self.top.frames['main']).document.all(name).隐藏//此处有待完善
}
}
</script>
在JS中设一全局变量rowIndex,在click事件中将行数附给此变量,在确定事件中用document.all.table.deleterow(rowIndex)方法将此行删除。手型和变蓝色就不用说了吧。
这样不可以啊,抱错,说
document.all.table为空或不是对象
如你的<table id="table1">如果这样写
javascript 中应这样document.all.table1.deleterow(2)
"table"应该是表的ID
用document.getElementById("table").deleteRow(2)
"document.all.t1.deleterow(1);
对象不支持该属性或方法
<html>
<head>
<title>新建网页 1</title>
</head>
<script>
function del()
{
document.all.t1.deleterow(1);
}
</script>
<body>
<form action="--WEBBOT-SELF--" method="POST" >
<!--webbot bot="SaveResults" u-file="fpweb:///_private/form_results.csv" s-format="TEXT/CSV" s-label-fields="TRUE" --><p>
<input type="button" value="删除" name="B1" onClick="del()">
</form>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="t1">
<tr>
<td width="20%">ds</td>
<td width="20%">sdf</td>
<td width="20%">d</td>
</tr>
<tr>
<td width="20%">w</td>
<td width="20%">s</td>
</tr>
</table>
</body>
</html>
<TABLE ID = oTable border=1>
<TR onclick="this.removeNode(true)" style="cursor:hand">
<TD>黑色金属</TD>
<TD>禁用</TD>
</TR>
<TR onclick="this.removeNode(true)" style="cursor:hand">
<TD>橡胶制品</TD>
<TD>禁用</TD>
</TR>
<TR onclick="this.removeNode(true)" style="cursor:hand">
<TD>料油脂</TD>
<TD>禁用</TD>
</TR>
<TR onclick="this.removeNode(true)" style="cursor:hand">
<TD>花轻产品</TD>
<TD>禁用</TD>
</TR>
</TABLE>
这样可以了还有:
如何得到d当前行?
<!--
function del(oTr){
/*for ie5+ or NS6+*/
oTr.parentNode.removeChild(oTr)
}
//-->
</script>
<TABLE ID = oTable border=1>
<TR onclick="del(this)" style="cursor:hand">
<TD>黑色金属</TD>
<TD>禁用</TD>
</TR>
<TR onclick="del(this)" style="cursor:hand">
<TD>橡胶制品</TD>
<TD>禁用</TD>
</TR>
<TR onclick="del(this)" style="cursor:hand">
<TD>料油脂</TD>
<TD>禁用</TD>
</TR>
<TR onclick="del(this)" style="cursor:hand">
<TD>花轻产品</TD>
<TD>禁用</TD>
</TR>
</TABLE>see more:
http://fason.nease.net/zhuanti/table/sample1.htm
删除是选中一条目录,然后按左边框架中的"删除目录",弹出一选择提示框,让用户确认是否真的要删除目录,按"确认"就删除一条目录,按"取消"就取消操作。如果没有选中目录,而按了左边框架中的“删除目录”,应提示用户选择要删除的目录。
不能直接删除.
.highlight{background-color:highlight;color:#FFFFFF}
</style>
<script language="JavaScript">
<!--
var currentRow=null
function DeleteRow(){
if(currentRow==null)return;
if(confirm('delete?')){
currentRow.parentNode.removeChild(currentRow)
}
}
function del(oTr){
if(!currentRow)currentRow=oTr
currentRow.className=""
oTr.className="highlight"
currentRow=oTr
}
//-->
</script>
<TABLE ID = oTable border=1>
<TR onclick="del(this)" style="cursor:hand">
<TD>黑色金属</TD>
<TD>禁用</TD>
</TR>
<TR onclick="del(this)" style="cursor:hand">
<TD>橡胶制品</TD>
<TD>禁用</TD>
</TR>
<TR onclick="del(this)" style="cursor:hand">
<TD>料油脂</TD>
<TD>禁用</TD>
</TR>
<TR onclick="del(this)" style="cursor:hand">
<TD>花轻产品</TD>
<TD>禁用</TD>
</TR>
</TABLE>
<input type=button value="DeleteRow" onclick="DeleteRow()">
<input type=button value="DeleteRow" onclick="parent.frames['right'].DeleteRow()">调用右框架的函数
function Table1_onclick() {
if (window.event.scrElement.tagname=="td"){
document.all.table1.deleterow( window.event.srcElement.parentElement.rowIndex)
}
}
tagname应为tagName
function DeleteRow(){
if(currentRow==null)return;
if(confirm('delete?')){
currentRow.parentNode.removeChild(currentRow)
currentRow=null;//删除后再初始化
}
}
<table id=b>
<tr name=0 onmousedown="check(this);">黑色金属 禁用 </tr>
<tr name=1 onmousedown="check(this);">橡胶制品 禁用 </tr>
<tr name=2 onmousedown="check(this);">油料油脂 禁用 </tr>
<tr name=3 onmousedown="check(this);">花轻产品 禁用 </tr>
</table>
<input type=hidden name="a"><script>
function check(id){
document.all('a').value=this.name;
}
</script>
左边框架
<input type=button value="删除" onclick="test();"><script>
function test(){
if(self.top.frames['main']).document.all('a').value.length<1{
alert("请选择要删除的目录");
}else{
var id=self.top.frames['main']).document.all('a').name;
self.top.frames['main']).document.all('b').deleteRow(id);
}
}
</script>
这里面 <tr name=0 onmousedown="check(this);">黑色金属 禁用 </tr>
使用 for(i=0;i<length;i++){}循环就可以 定位行的位置了! (如:name=i)
doing.......
}