I am an experienced developer, but I am new to JavaScript. Having an issue with JavaScript, I decided to use jsFiddle, which is also new to me.
I found this tutorial: http://doc.jsfiddle.net/tutorial.html
This is my fiddle: https://jsfiddle.net/richardpaulhall/y540ozwv/10/
-----
<div id='test'>Helloooo World!</div>
-----
$('test').addEvent('click', (function() {
$('test').set('html', 'Goodbye World!')
$('test').fade('out');
}));
-----
I set up the example as directed, but it did not work. It throws console errors.
fiddle.jshell.net/richardpaulhall/y540ozwv/10/show/:51 Uncaught TypeError: Cannot read property 'addEvent' of null
Line 51: $('test').addEvent('click', (function() {
The tutorial mentions setting the framework to Mootools. I chose 1.3.2
The tutorial used the alpha version.
In your fiddle
, you need to change the LOAD TYPE
to onDomReady
. (You can change this by clicking on the settings icon on the top-right corner of the javascript window). Now your js
will run only when the DOM is ready or all HTML elements are loaded.