你可以看看这个例子 它的意思是:获取对 ID 标签属性为指定值的第一个对象的引用。<!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>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<SCRIPT>
function fnGetId(){
var a = "javascript";
document.getElementById("f1").value = a;
}
</SCRIPT>
<input type="text" name="name" id="f1">
<INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<SCRIPT>
function fnGetId(){
var a = "javascript";
document.getElementById("f1").value = a;
}
</SCRIPT>
<input type="text" name="name" id="f1">
<INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货