'<div id="status" > CLOSE
'<input id="Button1"


Basically, i want to make an if then statement with the above elements.

if the CLOSE text becomes OPEN (1st element), it would automatically click the button (2nd element)

I have the following code but its insufficient or wrong. Can anyone help? Thank you..



theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
ctrlIdentity = curElement.GetAttribute("id").ToString
If ctrlIdentity = "Button1" Then
curElement.InvokeMember("click")
End If
Next

Im sorry if this question has been posted several times, but i still havent found any that answers my question.