当#textdiv为空时,隐藏#newplayer:
$(function() {
if ($('#textDiv').text().trim() == '') {
$('#newPlayer').hide();
}
});
案例:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id = "textDiv"></div>
<div id = "newPlayer">blah blah"</div>
jquery 判断标签内元素内容为空时,隐藏该模块
案例html:
<div class="box">
<h1>222</h1>
</div>
<div class="box">
<h1></h1>
</div>
js(记得先把jquery加上):
$("h1:empty").hide();
或
$("h1:empty").parent().hide();