显示/隐藏功能

时间:2014-12-27 20:35:07

标签: javascript html hide show show-hide

固定解决方案

    //Hide and Show Divs
function hideContent(d) {
    document.getElementById(d).style.display = "none";
}
function showInlineContent(d) {
    document.getElementById(d).style.display = "inline";
}
function showBlockContent(d) {
    document.getElementById(d).style.display = "block";
}
function reverseDisplay(d) {
    if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
    else { document.getElementById(d).style.display = "none"; }
}
    //Hide and Show Divs

    // Show Div <a href="javascript:showInlineContent('crafting2')">Click to show.</a>
function researchStick() {
    if (stick >= 1 && research1Progress < 100) {            // Want to be able to show progress
    stick = stick - 1;                                      // each time you click me I want to use 1 stick
    research1Progress = research1Progress + 5;              // each stick brings research progress up 5
    document.getElementById("stick").innerHTML = stick;     // Show the player the update
}
    if (research1Progress == 100) {                         // When reaches 100
        showInlineContent('crafting2');                         // show crafting2
}
    // when research hits 100 unlocks blunt object for crafting
    // this clickable button should hide after completion
    // add achievement for first research project

}

这是应用一些修复后的固定解决方案。如果函数有助于知道,能够调用多于一个,特别是因为我所采用的所有教程都没有特别指出。也许是显而易见的,但知道这有助于我成为java的新手,在我自己创建更多的代码

0 个答案:

没有答案