HTML Video mute button

后端 未结 2 1480
长发绾君心
长发绾君心 2021-01-27 01:27

I have tried to create a function in javascript to mute a html video, and change the icon below to a mute icon that i have downloaded. Need Help. The javascript has to be able t

2条回答
  •  天涯浪人
    2021-01-27 01:56

    demo - http://jsfiddle.net/victor_007/6cc9mhbb/

    on click of the button the icon will change

    $("video").prop('muted', true);
    
    $(".mute-video").click(function () {
        if ($("video").prop('muted')) {
            $("video").prop('muted', false);
            $(this).addClass('unmute-video'); // changing icon for button
    
        } else {
            $("video").prop('muted', true);
            $(this).removeClass('unmute-video'); // changing icon for button
        }
        console.log($("video").prop('muted'))
    });
    

提交回复
热议问题