javascript 为什么这个函数不工作()943wge4g [关闭]

vof42yt1  于 2023-08-02  发布在  Java
关注(0)|答案(1)|浏览(80)

**已关闭。**此问题为not reproducible or was caused by typos。它目前不接受回答。

此问题是由打印错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这一个是解决的方式不太可能帮助未来的读者。
3小时前关闭
Improve this question

document.getElementById("pt1_btn_next").onclick = function() {myFunction()}

function myFunction() {
    document.getElementById("pt1").style.visibility = hidden;
    document.getElementById("pt1_btn_next").style.visibility = hidden;
    document.getElementById("pt2").style.visibility = visible;
    document.getElementById("pt2_btn_video").style.visibility = visible;
}

我什么都试过了,为什么我测试的时候不管用

osh3o9ms

osh3o9ms1#

您需要引用值“hidden”和“visible”:

document.getElementById("pt1_btn_next").onclick = function() {myFunction()}

function myFunction() {
    document.getElementById("pt1").style.visibility = "hidden";
    document.getElementById("pt1_btn_next").style.visibility = "hidden";
    document.getElementById("pt2").style.visibility = "visible";
    document.getElementById("pt2_btn_video").style.visibility = "visible";
}

字符串

相关问题