在jQuery中隐藏/显示图像 [英] hide/show a image in jquery

查看:89
本文介绍了在jQuery中隐藏/显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在单击超链接时显示/隐藏图像?

How to show/hide the image on clicking the hyperlink?

<script>
function getresource(id)
{
    if(id==4)
    {
       //show image
     }
    else if(id==5)
    {
         //hide image
     }

 } 
</script>
<a href="#" onclick="javascript:getresource('4');">Bandwidth</a>
<a href="#" onclick="javascript:getresource('5');">Upload</a>
<p align="center"> 
  <img id="img3" src="/media/img/close.png" style="visibility: hidden;" />
  <img id="img4" src="/media/img/close.png" style="visibility: hidden;" />
</p>

推荐答案

您要隐藏什么图像?假设所有图片,以下内容均应工作:

What image do you want to hide? Assuming all images, the following should work:

$("img").hide();

否则,使用选择器,您可以找到所有包含div的子元素的图像,并将其隐藏.

Otherwise, using selectors, you could find all images that are child elements of the containing div, and hide those.

但是,我强烈建议您阅读Jquery文档,您自己可以解决这个问题: http://docs .jquery.com/Main_Page

However, i strongly recommend you read the Jquery docs, you could have figured it out yourself: http://docs.jquery.com/Main_Page

这篇关于在jQuery中隐藏/显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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