梦之都
JavaScript教程
,
document
对象示例
xhtml
css
javascript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>JavaScript document 对象示例</title> </head> <body> <form name="form1"><a href="http://www.dreamdu.com/xhtml/" name="a1">xhtml</a></form> <form name="form2"><a href="http://www.dreamdu.com/css/" name="a2">css</a></form> <form name="form3"><a href="http://www.dreamdu.com/javascript/" name="a3">javascript</a></form> <input type="button" value="显示第二个表单的名称" onclick="alert(document.forms[1].name)" /> <input type="button" value="显示第二个表单的名称第二种方法" onclick="alert(document.forms['form2'].name)" /> <input type="button" value="显示第三个链接的名称" onclick="alert(document.links[2].name)" /> <input type="button" value="显示第三个链接的名称第二种方法" onclick="alert(document.links['a3'].name)" /> <input type="button" value="显示第三个链接href属性的值" onclick="alert(document.links[2].href)" /> </body> </html>