JavaScript DOM Manipulation

Here are some of my notes in how to do some of the dome manipulation using JavaScript.

How to change a picture when clicking a button

There are several ways to do this one is, “event listeners”, and other would be using “onclick”

In the following examples, we have the pictures in a folder call “IMG” and I name them numerically, from 0 to 36. and the js code generate a random number and it gets cocatenated in to a string containing the location and name of the file to load to img-frame.

Example using Function and onclick=””

Example using event listeners.

Here are some examples of the code working:

works good.

.



Copyright 2017. All rights reserved.

Posted July 23, 2017 by Edmundo in category "JS