Accessing and manipulating the DOM

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:

Figure 3.2: The DOM can be accessed and manipulated by a JavaScript program and/or a Go program (using GopherJS)

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.50.87