You will need to use some type of selector.
The GetElementByID method works best because if the HTML file is formatted correctly then there should only be one element with that unique ID.
The GetElementFromPoint will return an element based on the X,Y coordinate of the document, this is best used in the Document's Click event.
The GetElementByTagName name will return a collection of elements and works if you know the tag type of the element, such as <button>...</button>
or <p>...</p>
. To help narrow down which element you want, you will need to then iterate through the returned collection and compare either the element's attributes if you know their respective values or the element's text via the InnerHTML property.
The last and least effective method is the All property which returns every element in the document. The reason why this is the least effective is because at least with GetElementByTagName, you can narrow down the collection based on the tag's name.
However, let's assume that you have the following markup:
<body>
<p>Look at my super complex HTML markup.</p>
<button>Click Me</button>
<button>No, click me!</button>
</body>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…