A basic default example with a click event.

Click me for sound
var sound0 = new JsSound('id', 'click', ['sound/crash1.wav', 'sound/crash1.mp3']);

An example using multiple targets with the same class.

Sound on class - click me Sound on class - click me Sound on class - click me var sound1 = new JsSound('class', 'clank', ['sound/clank.wav', 'sound/clank.mp3']);

An example using the optional fourth parameter, which specifies what type of event to listen for, rather than the default click action.

On mouseover and mouseout produce different sounds
var sound2 = new JsSound('id', 'box', ['sound/crash1.wav', 'sound/crash.mp3'], 'mouseover');
var sound3 = new JsSound('id', 'box', ['sound/clank.wav', 'sound/clank.mp3'], 'mouseout');

JsSound on the third parameter accepts either an array of files to use ( each of these should be of the same sound but different formats, in order to provide a wider range of browser matches). This example shows a string being used.

Single sound
var sound4 = new JsSound('id', 'single', ['sound/clank.wav', 'sound/clank.mp3']);