The tags MethodIn the Internet Explorer, the tags method retrieves a collection of objects that have the specified HTML tag name . You can see the support for this method in Table 6.53. Table 6.53. The tags Method
This method is part of collections like the all and forms collections. We've already put the tags method to work in Chapter 4: (Listing 04-11.html on the web site)<HTML> <HEAD> <TITLE> Accessing HTML Elements </TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function getText() { if(navigator.appName == "Netscape") { alert("document.form1.text1.value = " + document.form1.text1.value) alert("document.forms[0].text1.value = " + document.forms[0].text1.value) alert("document.getElementsByName(\"text1\")[0].value = " + document.getElementsByName("text1")[0].value) alert("document.getElementsByTagName(\"INPUT\")[0].value = " + document.getElementsByTagName("INPUT")[0].value) } if (navigator.appName == "Microsoft Internet Explorer") { alert("document.form1.text1.value = " + document.form1.text1.value) alert("document.forms[0].text1.value = " + document.forms[0].text1.value) alert("document.all.text1.value = " + document.all.text1.value) alert("document.all[\"text1\"].value = " + document.all["text1"].value) alert("document.all.tags(\"INPUT\")[0].value = " + document.all.tags("INPUT")[0].value) alert("document.getElementsByName(\"text1\")[0].value = " + document.getElementsByName("text1")[0].value) alert("document.getElementsByTagName(\"INPUT\")[0].value = " + document.getElementsByTagName("INPUT")[0].value) } } // --> </SCRIPT> </HEAD> <BODY> <H1>Accessing HTML Elements</H1> <FORM NAME="form1"> <INPUT TYPE="TEXT" NAME="text1" ID="text1"> <INPUT TYPE="BUTTON" VALUE="Click Me!" ONCLICK="getText()"> </FORM> </BODY> </HTML> |