将图像可见性更改为true或false [英] Change image visiblity to true or false

查看:151
本文介绍了将图像可见性更改为true或false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生/女士,
我正在做一个网络项目.在该项目中,我想隐藏一个图像并使其他图像可见,而不是隐藏的图像.使用的图像控件是asp:Image.
我编写的代码如下:

Respected sir/madam,
I am working on a web project. In that project I want to hide an image and make another image visible instead of the hidden one. The image control used is asp:Image.
The code which I have written is as follows:

<script  type="text/javascript">
function changeImage() 
{
  document.getElementById("req1").style.display = "hidden";
  document.req1.visibility = "hide"
  req1.style.dispaly = ''none'';
  alert(''Client side'');
}
</script>



但问题是,在客户端上单击图像的可见性没有改变.请帮忙!



But the thing is that on client click the images'' visibility is not changing. Please help!

推荐答案

document.req1.visibility = "hide"



hide不是有效的命令



hide is not a valid command

document.req1.visibility = "hidden"



另外,请确保正确引用了元素.另外,尽管我假设您在此处发布时添加了错别字,但请确保您的拼写正确.



Also make sure the elements are referenced properly. Also, although I assume you added typos when posting here, but make sure of your spelling.


感谢您回复Mark先生,
但这也不起作用,
我找不到问题所在.从过去的三天开始,我一直在做这个愚蠢的事情,并从头开始.我正在工作的页面上没有任何更改,并且从今天起就不再调用javascript.我不明白是什么问题.我受够了.请帮忙!!!
thanks for your revert Mr. Mark,
but that is also not working,
i am not able to find what the problem is. from last 3 days i am working on this silly thing and scratching my brain out. There is not a single change in the page on which i am workin and from today the javascript is not being invoked. i am not able to understand what the problem is. i am fed up. please help!!


尝试一下...

过去我发现我必须非常明确,并使用object.style.visibility属性才能使这种类型的行为正常工作.

我开始只是在javascript中创建对象,因此我可以更轻松地进行调试.我知道这不是必需的,但是它使代码更易于理解. (完全是我自己的看法)

Try this instead...

I have found in the past that I had to be very explicit and use the object.style.visibility attribute to make this type of behavior work properly.

Creating the object upfront in javascript was something I started doing only so that I would have the ability to debug easier. I know it isn''t necessary, but it makes the code easier to understand. (Totally my own opinion)

<script type="text/javascript">

function changeImage()
{
    var obj = document.getElementById("req1");
    if( obj )
    {
        obj.style.visibility = "hidden";
    }
    else
    {
        alert( "req1 is null" );
    }
}

</script>


这篇关于将图像可见性更改为true或false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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