【发布时间】:2017-09-09 09:31:31
【问题描述】:
当前使用 contains() 匹配特定关键字。如何扩展它以包含多个关键字? 尝试过使用 || (或)运算符,但没有乐趣。
<!-- Product names include Apple iPad, Acer Iconia, Lenovo Thinkpad -->
<h1 id="pbtitle">Apple iPad 3</h1>
<div class="install_option" style="display:none;">
<div style="box-sizing:border-box; float:left;">
<a href="https://www.exmaple.com/acc" target="_blank">
<h3 style="font-weight:bold;">Would you like to view accessories?</h3>
</a>
</div>
</div>
$(".install_option").each(function() {
if($("h1#pbtitle:contains:contains('Acer' || 'Lenovo' || Apple )").length>0){
$('.install_option').css('display','block');
}
});
【问题讨论】:
标签: javascript jquery contains