JavaScript's document object contains the actual content of the page, so the document object can be used to obtain the page content, such as the page title and each form value.
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>js basic</title></head><body><p>1. Use the Document object to obtain the page title</p><hr/><p>2. Use the Document to access the two forms</p><p>First, the value of the text box</p><form name="textform"> <input name="textname" type="text" value="Please enter text"/></form><p>Second, the value of the button</p><form name="submitform"> <input name="submitname" type="submit" value="Submit in the first form"/></form><hr/><p>The following is the obtained value</p><table cellpacing="4" cellpadding="2"> <tr> <td>The title of this page is: </td> <td> <b><script>document.write(document.title)</script></b></td> </tr> <tr> <td>This page contains forms: </td> <td><b><script>document.write(document.forms.length)</script></b></td> </tr> <tr> <td>Get the value of the text box: </td> <td><b><script>document.write(window.document.textform.textname.value)</script></b></td> </tr> <tr> <td>Get the button's value: </td> <td><b><script>document.write(window.document.submitform.submitname.value)</script></b></td> </tr></table></body></html>
The above implementation code for obtaining page document content using JavaScript is all the content shared by the editor. I hope it can give you a reference and I hope you can support Wulin.com more.