javascript - Switch image with callback code with jquery -
i need switch 2 image .click event on same image, callback function on 1° image , 2° image.
my purpose create simple audio player site mute/unmute function click image.
i have "icontrue.png" , "iconfalse.png".
the css on "iconfalse.png" set on "display:none"
this html:
<img src="http://www.gastronomiasanfilippo.it/img/icontrue.png" id="true" class="show" /> <img src="http://www.gastronomiasanfilippo.it/img/iconfalse.png" id="false" class="hide"/> this css:
#false{ cursor:pointer; } #true{ cursor:pointer; } .show{display:inline;} .hide{display:none;} this jquery:
$("#true").click(function(){ $(this).addclass("hide"); $("#false").css("display","inline"); }); with code can't switch image ever click event , can't have callback function, what's way this?
this jfiddle: http://jsfiddle.net/b9ykmtlp/
try this:
html:
<div id="mute-unmute"></div> js:
var muted = false; $("#mute-unmute").click(function () { muted = !muted; if (muted) { $(this).addclass("muted"); // mute(true); } else { $(this).removeclass("muted"); // mute(false); } }); css:
#mute-unmute { width: 50px; height: 50px; background-image: url(http://www.gastronomiasanfilippo.it/img/icontrue.png); cursor: pointer; } #mute-unmute.muted { background-image: url(http://www.gastronomiasanfilippo.it/img/iconfalse.png); }
Comments
Post a Comment