<div id="content"></div> <input type="button" id="btn" value="点击"> var content = document.getElementById("content"); var btn = document.getElementById("btn"); btn.onclick = function(){ if(content.innerText == ''){ content.style.display = 'none' } }
content.innerText == ''