I have this below script
$.fn.SoundToggle = function() {
var sound_staus = $('#soundstatus').data('status');
if (sound_staus === 'mute')
{
$('#soundstatus').data('status', 'unmute');//ui-icon ui-icon-volume-off
$("#soundstatus span").removeClass("ui-icon ui-icon-volume-off").addClass("ui-icon ui-icon-volume-on");
} else
{
$('#soundstatus').data('status', 'mute');
$("#soundstatus span").removeClass("ui-icon ui-icon-volume-on").addClass("ui-icon ui-icon-volume-off");
}
}
And html
<a class="button" title="Sound Mute/Unmute" data-status="mute" onClick="$(this).SoundToggle();" id="soundstatus">
<span class="ui-icon ui-icon-volume-on"></span>
</a>
I want to toggle jquery ui Speaker Mute & unmute two icons on click.
But my above code is not showing output properly, instead of removing previous its showing two icons at once like this image:

Please help me why my code is not working fine.
ui-icon?this