本文介绍了如何在2张图像之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用此代码在播放按钮和暂停按钮之间切换,但似乎不起作用.当点击
Im trying to use this code to toggle between a play and pause button but it doesn't seem to be working. How can I get it toggle between the 2 images when the are clicked
$("#infoToggler").click(function()
{
if($(this).html() == "<img src="http://tympanus.net/PausePlay/images/play.png" width="60px" height="60px"/>")
{
$(this).html("<img src="http://maraa.in/wp-content/uploads/2011/09/pause-in-times-of-conflict.png width="60px" height="60px"/>");
}
else
{
$(this).html("<img src="http://tympanus.net/PausePlay/images/play.png" width="60px" height="60px"/>");
}
});
谢谢
推荐答案
另一种可能更简单的处理方式:
A different maybe easier way to handle it:
$("#infoToggler").click(function() {
$(this).find('img').toggle();
});
<div id="infoToggler">
<img src="image1.png" width="60px" height="60px"/>
<img src="image2.png" width="60px" height="60px" style="display:none"/>
</div>
这篇关于如何在2张图像之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!