我試過這個,但obv它沒有工作。我對JS很新,我該怎麼做?如何讓div在onclick nr 2之後消失?
function test() {
if(document.getElementById('div1').style.display = 'block'){
document.getElementById('div1').style.display = 'none';
}
if(document.getElementById('div1').style.display = 'none'){
document.getElementById('div1').style.display = 'block';
}
}
試試這個document.getElementById('div1')。hide(); –
你可以發佈JS小提琴嗎?另外,如果我沒有錯,=是一個賦值操作符,並且==驗證它。 –
@SatejS我甚至不能讓「塊」在小提琴中工作:S https://jsfiddle.net/7wfz63ue/1/ – anonym