window.addEventListener('load', () => {
// noinspection JSUnresolvedVariable
let audioCtx = new (window.AudioContext || window.webkitAudioContext)();
let xhr = new XMLHttpRequest();
xhr.open('GET', 'audio-autoplay.wav');
xhr.responseType = 'arraybuffer';
xhr.addEventListener('load', () => {
let playsound = (audioBuffer) => {
let source = audioCtx.createBufferSource();
source.buffer = audioBuffer;
source.connect(audioCtx.destination);
source.loop = false;
source.start();
setTimeout(function () {
let t = document.createElement('p');
t.appendChild(document.createTextNode((new Date()).toLocaleString() + ': Sound played'));
document.querySelector('.output').appendChild(t);
playsound(audioBuffer);
}, 1000 + Math.random()*2500);
};
audioCtx.decodeAudioData(xhr.response).then(playsound);
});
xhr.send();
});
To collect a group of elements, we pass the selector to the jQuery function using…
jQuery is a lightweight, "write less, do more", JavaScript library. The purpose of jQuery is…
HTML:- [crayon-692a614724d79122190716/] CSS:- [crayon-692a614724d7d690817197/] JavaScript:- [crayon-692a614724d7f984395475/]
Prevent users typing special characters in text box, textarea, etc. [crayon-692a614724e5e876458363/] ^[a-zA-Z]+$ Alphabets ^[a-zA-Z\s]+$ Alphabets…
Any interactive web site has form input - a place where the users input different…
[crayon-692a6147250ab599166497/]