IHTMLDocument2 doc = getDocument(); IHTMLElement element = doc.getElementById("myElementID");
IHTMLElement element = ...; // get an element element.style.backgroundColor = "red"; element.style.color = "white";
IHTMLElement element = ...; // get an element element.addEventListener("click", new EventHandler((sender, args) => { // do something on click }));This example shows how to attach an event listener to an HTML element. In this case, we are adding a listener to handle the `click` event. These examples use the MSHTML library, which is included with Internet Explorer and the .NET Framework. To use this library, you must add a reference to the Microsoft.mshtml assembly in your project.