popup sound checkbox checked - Free Download Display A Popup And Play A Sound When A Checkbox Is Checked

Free Download Display A Popup And Play A Sound When A Checkbox Is Checked

Posted on

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.

popup sound checkbox checked - Free Download Display A Popup And Play A Sound When A Checkbox Is Checked
File Size: 91.7 KB
Views Total: 85
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

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   ... popup content ...
3 </div>

2. Add a sound effect to the page.

1 <audio class="audiofile">
2   <source src="sound/bell.mp3" type="audio/mpeg">
3 </audio>

3. Apply your own styles to the popup box.

1 .popup-content {
2   width: 400px;
3   position: fixed;
4   bottom: 50%;
5   right: 30px;
6   display: block;
7   z-index: 999;
8 }

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
01 (function ($) {
02   $('#click-button').change(function () {
03     if (this.checked) {
04       $('.popup-content').show(function () {
05         setTimeout(function () {
06           $(".popup-content").fadeOut(2000);
07         }, 6000);
08       });
09       $('.audiofile')[0].play();
10     } else {
11       $('.popup-content').hide();
12     }
13   });
14 })(jQuery)