我有这个html页面(我只有javascript代码显示,隐藏div):
<div class="rigaTwo">
<div class="col1">
<p class="room">AULA E</p>
<p class="where">PIAZZA A</p>
</div>
<div class="col2 half">
<p class="when">09:00 - 13:00</p>
</div>
<div class="col3">
<p class="what">METODI</p>
<p class="who">ZAP</p>
</div>
</div>
<div class="rigaTwo">
<div class="col1">
<p class="room">AULA D</p>
<p class="where">PIAZZA A</p>
</div>
<div class="col2 half">
<p class="when">10:00 - 12:00</p>
</div>
<div class="col3">
<p class="what">PROF</p>
<p class="who"></p>
</div>
</div>
<div class="rigaOne">
<div class="col1">
<p class="room">STUDIO</p>
<p class="where">VIALE Europa</p>
</div>
<div class="col2 half">
<p class="when">10:00 - 13:00</p>
</div>
<div class="col3">
<p class="what">PROF.SSA</p>
<p class="who"></p>
</div>
</div>
<div class="rigaTwo">
<div class="col1">
<p class="room">AULA F</p>
<p class="where">PIAZZA</p>
</div>
<div class="col2 half">
<p class="when">10:00 - 14:00</p>
</div>
<div class="col3">
<p class="what">PROF</p>
<p class="who"></p>
</div>
</div>
<div class="rigaTwo">
<div class="col1">
<p class="room">AULA B</p>
<p class="where">PIAZZA</p>
</div>
<div class="col2 half">
<p class="when">11:00 - 14:00</p>
</div>
<div class="col3">
<p class="what">PROF</p>
<p class="who"></p>
</div>
</div>
<div class="rigaTwo">
<div class="col1">
<p class="room">AULA</p>
<p class="where">PIAZZA</p>
</div>
<div class="col2 half">
<p class="when">11:00 - 17:00</p>
</div>
<div class="col3">
<p class="what">SPEV</p>
<p class="who"></p>
</div>
</div>
<div class="rigaOne">
<div class="col1">
<p class="room">AULA EUROPA 3</p>
<p class="where">VIALE Europa</p>
</div>
<div class="col2 half">
<p class="when">14:00 - 18:00</p>
</div>
<div class="col3">
<p class="what">COMUNICAZIONE.</p>
<p class="who">CAV</p>
</div>
</div>
<div class="rigaTwo">
<div class="col1">
<p class="room">AULA A</p>
<p class="where">PIAZZA</p>
</div>
<div class="col2 half">
<p class="when">14:00 - 18:00</p>
</div>
<div class="col3">
<p class="what">LAB</p>
<p class="who">ALBA</p>
</div>
</div>
我想过滤房间(Name_of_room
),因此您只能看到所选房间,如果有任何行包含房间显示的名称&#34;没有计划的活动&#34;,它&#39可能吗?
这是hide / show div的javascript代码:
javascript:(function(){
$( \".rigaOne\").hide();
$( \".rigaTwo\").hide();
$( \".rigaOne:contains("+title+")\" ).show();
$( \".rigaTwo:contains("+title+")\" ).show();
$( \".room:contains("+title+")\" ).show();
}
我在Android中有一个WebView,这个代码只显示包含标题的div,如果所有div都隐藏了我想显示&#34;没有计划的活动&#34;
答案 0 :(得分:0)
您可以使用以下脚本
$('p').each(function(){
if($(this).html() === 'name of the room'){
$(this).html('no planned activities');
}
})
答案 1 :(得分:0)
我刚刚找到了解决方案并且它的工作原理:
javascript:(function(){
$( \".rigaOne\").hide();
$( \".rigaTwo\").hide();
$( \".rigaOne:contains("+title+")\" ).show();
$( \".rigaTwo:contains("+title+")\" ).show();
$( \".room:contains("+title+")\" ).show();
var count = $('.room:visible').size();
if(count<1){
document.write(\"No planned activities\");
}
}