简体   繁体   English

下拉菜单隐藏图片onchange javascript

[英]dropdown hide image onchange javascript

I'm creating a mobile application on monaca.io. 我正在monaca.io上创建一个移动应用程序。 I try to hide image when user select an option from combobox but nothing happens. 当用户从组合框中选择一个选项但没有任何反应时,我尝试隐藏图像。

function setImageVisible(id, visible) {
    var img = document.getElementById(id);
    img.style.visibility = (visible ? 'visible' : 'hidden');
}

Thank you 谢谢

This code looks ok. 这段代码看起来还可以。 As you states in your comment that it's working on chrome, I think this is not working because of some issue in the monaca emulator. 正如您在评论中指出它正在chrome上运行一样,我认为由于monaca模拟器中的某些问题,它无法正常工作。

I'd suggest you try to debug your Code that you can check here: 我建议您尝试调试您可以在此处检查的代码:

var img = document.getElementById(id);

If your var img successfully gets the image. 如果您的var img成功获取图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM