VBA getelementsbyclassname use with getelementsbyid
<p>I'm trying to write a short VBA code to click on a button on a website by searching first by its classname, and then by id: </p>

<pre><code>Sub Autoclick[enter image description here][1]()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://stackoverflow.com/"
IE.Visible = True

While IE.Busy
DoEvents
Wend

IE.Document.getElementsByClassname("nav mainnavs").getElementById("nav-jobs").Click

End Sub
</code></pre>

<p>However the code would not click on the Jobs button. I understand that I can just use getelementbyid directly, but I'd still like to know why using getelementsbyclassname and getelementbyid together would not work. </p>

<p>Attached image contains the html code of the website. </p>

<p>Thanks a lot for any help!</p>