Image will not switch between hidden and show

前端 未结 1 1675
一整个雨季
一整个雨季 2021-01-24 15:03

I cannot get an image to switch back and forth between \'hidden\' and \'show\'

I\'m using ideas from How to create a hidden in JavaScript?

1条回答
  •  一向
    一向 (楼主)
    2021-01-24 16:05

    The visibility style property has values of visible and hidden.

    There is no show value.

    function init() {
         document.getElementById("light").style.visibility = "hidden";
         var onButton = document.getElementById("onButton");
         onButton.onclick = function() {
            demoVisibility();
         }
       }
    
     function demoVisibility() {
         document.getElementById("light").style.visibility = "visible";
     }
    

    0 讨论(0)
提交回复
热议问题