简体   繁体   English

如何使事情在负载下消失

[英]How to make things dissapear on load

function vanish() {
    document.getElementById("priceCheck").style.visibility = "hidden";
}

<body onload="vanish">
    <div>
        <input type="button" class="input_button" name="onestarbtn" value="One Star"/>
        <input type="button" class="input_button" name="twostarbtn" value="Two Star"/>
        <input type="button" class="input_button" name="threestarbtn" value="Three Star"/>
        <input type="button" class="input_button" name="fourstarbtn" value="Four Star"/>
        <input type="button" class="input_button" name="fivestarbtn" value="Five Star"/>    
    </div>

    <div id="priceCheck">
        test1
    </div>    
    <div id="priceCheck">
        test2
    </div>    
    <div id="priceCheck">
        test3
    </div>    
    <div id="priceCheck">
        test4
    </div>    
    <div id="priceCheck">
        test5
    </div>
</body>

I want it to load all the tests with the "priceCheck" id's to be invisible on load. 我希望它加载所有带有“ priceCheck” ID的测试,以便在加载时不可见。 I then want to be able to click each of the input buttons, depending on the star(onestarbtn, twostar...) and corresponding with the test number, to make the priceCheck's visible. 然后,我希望能够单击每个输入按钮,具体取决于星级(onestarbtn,twostar ...)并与测试编号相对应,以使priceCheck可见。 I have an idea but havn't quite gotten to that part. 我有一个主意,但还没有完全了解。 I, however, cannot seam to get the tests to vanish on load. 但是,我无法缝合以使测试在负载中消失。 Any help would be greatly appreciated. 任何帮助将不胜感激。

Add style="display:none" to all of them and set style to block when you want to show it. 向所有人添加style =“ display:none”,并将样式设置为在您要显示时阻止。 The problem seems a bit too straight forward, so maybe i did not fully understand. 这个问题似乎太直接了,所以也许我没有完全理解。

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

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