在两个图像之间切换。 [英] Toggle between two images.

查看:88
本文介绍了在两个图像之间切换。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我是Javascript和Jquery的新手,所以我的问题是我有两张图片

一个edit.png和另一个ok.png。所以我的问题是,如果我点击edit.png它应该显示edit.png图标,但如果我点击保存按钮然后它应该更改为ok.png图像所以我怎么能切换在Jquery中的图像之间。



< pre lang =HTML> 
< div class =edit-button>
< img src =edit-icons.pngwidth =40height =40alt =编辑>
< / div>
< div class =ok-button>
< img src =ok-icons.pngwidth =40height =40alt =OK>
< / div>





我尝试过:



< pre lang =Javascript> 

$('。ok-button')。hide();

$('。edit-button,.ok-button')。on('click',function(){

$('。edit-button,。 ok-button')。toggle()
});

解决方案

('。ok-button')。hide ();

( '编辑按钮,.ok按钮 ')上(' 点击',函数(){

(。 '.edit-button,.ok-button')。toggle()
});


Hello, i am new one to Javascript and Jquery, so my question is i have two images
one "edit.png" and another "ok.png". So my queestion is, if i click on the "edit.png" it should shows "edit.png" icon, but if i click on the save button then it should be change to "ok.png" image so how can i toggle between images in Jquery.

<pre lang="HTML">
<div class="edit-button">
<img src="edit-icons.png" width="40" height="40" alt="Edit">
</div>
<div class="ok-button">
<img src="ok-icons.png" width="40" height="40" alt="OK">
</div>



What I have tried:

<pre lang="Javascript">

$('.ok-button').hide();

        $('.edit-button,.ok-button').on('click',function(){

        	$('.edit-button,.ok-button').toggle()
        });

解决方案

('.ok-button').hide();


('.edit-button,.ok-button').on('click',function(){


('.edit-button,.ok-button').toggle() });


这篇关于在两个图像之间切换。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆