document.addEventListener('DOMContentLoaded', function() { var toggleSoundButton = document.querySelector('.toggle_sound'); var icon = document.querySelector('.toggle_sound i'); var heroBackgroundVideo = document.querySelector('.video video'); toggleSoundButton.addEventListener('click', function (event) { if (heroBackgroundVideo.muted !== false){ heroBackgroundVideo.muted=false; icon.classList.add("fa-volume-up"); } else { heroBackgroundVideo.muted=true; icon.classList.remove("fa-volume-up"); } }); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter