javascript write问题

来源:百度知道 编辑:UC知道 时间:2024/06/09 07:03:06
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>

</head>

<body>
<form name="test1">
<input type="text" name="name1" value="1"/>
<input type="submit" name="Submit" onclick="look()" />
</form>
<form name="test2">
<input type="text" name="name2" value="2"/>
<input type=

如果你是做调试呢。

就使用 alert

用 document.write() 方法,是你在页面加载的时候使用。

比如

<script language="javascript">
function look()
{
document.write(document.test1.name1.value);
document.write(document.test2.name2.value);
}

look();//直接调用。
</script>

因为document.write 书写的手会覆盖前面的吧。所以就只有了。
用innerHTML啥~