O'Reilly logo

Moodle JavaScript Cookbook by Alastair Hole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changing an element's color

In this recipe, we will animate an element changing color. We will change the background color of the div element from blue to green.

Here, we can see the key steps in this animation by looking at a selection of frames:

Changing an element's color
Changing an element's color
Changing an element's color

How to do it...

We begin by creating a PHP page to set up a basic Moodle programming environment. In this case, anim_color.php, with the following content:

<?php require_once(dirname(__FILE__) . '/../config.php'); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required