一个使用innerHTML的简单例子: <P onmouseover="this.innerHTML='<B>Mouse out to change back.</B>'" onmouseout="this.innerHTML='<I> Mouse over again to change.</I>'"> <I>Mouse over this text to change it.</I></P> 一个使用innerText的例子: <P ID=oPara>Here's the text that will change.</P> <BUTTON onclick="oPara.innerText='WOW! It changed!'">Change text</BUTTON> <BUTTON onclick="oPara.innerText='And back again'">Reset</BUTTON> 注:你可以给表格设置ID,然后像前面几位所说的那样应用就可以了 Good luck!
你可以参考一下API的说明,主要看 HTMLEditorKit这个东西,在 javax.swing.text.html.*下有你想要的东西。
table.rows(x).cells(x).innerText
<head>
<script language="javascript">
function doChange() {
document.all.hello.innerHTML="this is change";
}
</script>
</head>
<body>
<form name="frmHello">
<table>
<tr><td id=hello>thank you</td>
<tr><td><input type=button value=dochange onclick="doChange()">
</table>
</form>
</body>
</html>
在function这里就可以对td中的内容进行改变。当然也可以显示出来。
常见的做法是servlet中返回一个字符串,或是用script返回字符串达到
动态改变网页的目的。
是一个由ROW组成的COLLECTION,而每一个ROW又由一些CELL组成,这些CELL的集合叫CELLS,也是一个COLLECTION,如果想对表格中的任何一个CELL(也就是<TD></TD>)的属性进行编辑修改或其它操作,只需要找到这个CELL就可以了,比如下面的TABLE<table id=table>
<tr id=tr>
<td id=td1></td>
<td id=td2></td>
</tr>
</table>它有一个TR,也即一个ROW,TR中有两个TD,也即两个CELL,若要存取第二个TD,可以用下面的方法table.rows[0].cell[1].innerText 或
table.rows[0].cell[1].innerHTML当然,若存取固定单元格的内容,则可以直接用ID操作,如楼上所言。
table.rows[0].cells[1].innerText
<P onmouseover="this.innerHTML='<B>Mouse out
to change back.</B>'"
onmouseout="this.innerHTML='<I>
Mouse over again to change.</I>'">
<I>Mouse over this text to change it.</I></P>
一个使用innerText的例子:
<P ID=oPara>Here's the text that will change.</P>
<BUTTON onclick="oPara.innerText='WOW! It changed!'">Change text</BUTTON>
<BUTTON onclick="oPara.innerText='And back again'">Reset</BUTTON>
注:你可以给表格设置ID,然后像前面几位所说的那样应用就可以了
Good luck!