通过使用 jQuery 的 contains() 选择器,你能够查找元素内容中的文本。若文本不存在,该元素将被隐藏:

var search = $('#search').val();
$('div:not(:contains("' + search + '"))').hide();