How to apply a fade effect in HTML5 mute button
<p>I have a mute button that simply mute a HTML5 audio object. It does mute the track but I like to add a fade in/out effect.
I tried it by adding <code>audio.animate({volume: 0}, 2000);</code> but its not working.</p>

<p>Any idea? </p>

<p>Thank in advance!</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>audio = new Audio();
audio.src = "http://myst729.qiniudn.com/within-temptation_pale.mp3"
audio.play();

$(".mute").on("click tap", function(){
 if (audio.muted) {
            audio.animate({volume: 1}, 2000);
            audio.muted = false;
            $(this).text("mute");

        } else {
            audio.muted = true;
            audio.animate({volume: 0}, 2000);
            $(this).text("unmute");
        }
});</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;button class="mute"&gt;mute&lt;/button&gt;</code></pre>
</div>
</div>
</p>