This time I will share jQuery Plugin and tutorial about Display A Popup And Play A Sound When A Checkbox Is Checked, hope it will help you in programming stack.
A tiny jQuery script that enables a checkbox to toggle a notification popup and play a sound when checked.
Ideal for I Agree checkboxes, which informs visitors that your terms or legal agreements have been got consent.
How to use it:
1. Add your content to the popup box.
1 |
< div class = "popup-content" style = "display: none;" > |
2. Add a sound effect to the page.
1 |
< audio class = "audiofile" > |
2 |
< source src = "sound/bell.mp3" type = "audio/mpeg" > |
3. Apply your own styles to the popup box.
4. Load the necessary jQuery library in the document.
1 |
< script src = "/path/to/cdn/jquery.min.js" ></ script > |
5. Enable your checkbox input to toggle the popup box.
1 |
< input type = "checkbox" name = "checkbox" id = "click-button" > I Agree |
02 |
$( '#click-button' ).change( function () { |
04 |
$( '.popup-content' ).show( function () { |
05 |
setTimeout( function () { |
06 |
$( ".popup-content" ).fadeOut(2000); |
09 |
$( '.audiofile' )[0].play(); |
11 |
$( '.popup-content' ).hide(); |