As noted previously, we can use JavaScript to access and manipulate the DOM for a given web page. Since GopherJS transpiles to JavaScript, we now have the capability to access and manipulate the DOM within the confines of Go. Figure 3.2 depicts a JavaScript Program accessing/manipulating the DOM along with a Go program also accessing/manipulating the DOM:
Now, let's take a look at a few simple programming snippets, where we can access the JavaScript functionality using Go, followed by some basic DOM operations using JavaScript and their equivalent instruction in GopherJS. For the time being, let's get a preview of what coding with GopherJS looks like. These concepts will be explained in further detail, as fully fleshed out examples, later in this chapter.