如何用js点击一个div来显示另外一个div

2025-03-22 17:52:37
推荐回答(2个)
回答1:

这个到是不难,代码如下

点击显示另一个div

点击后显示的div




function showOtherDiv(){
//获取要显示的div对象
var  otherDiv=document.getElementById('otherDiv');
//显示
otherDiv.style.display="block";
}

回答2:

html:


    Click Me

JS:

document.getElementById("div1").onclick = function(){
    document.getElementById("div2").style.display = "none";
}

相关问答
最新问答