[英]:contains() works fine in Opera, IE (7,8) and Chrome but in firefox
I have written a search filter. 我写了一个搜索过滤器。 It shows/hides some thumbnails in a video gallery based on text typed into an input field. 它根据输入字段中的文本显示/隐藏视频库中的一些缩略图。 Te input field has a keyUp event. 输入字段具有keyUp事件。
$('.videoSearch').keyup(function(e){
var searchString = $(e.srcElement).val();
var el = $($(e.srcElement).parents().find('.videoThumbs').first());
$(el).find(".title:not(:contains('"+searchString+"'))").each(function(i,e){
$(e).parent().parent().parent().parent().parent().parent().fadeOut(300);
});
$(el).find(".title:contains('"+searchString+"')").each(function(i,e){
$(e).parent().parent().parent().parent().parent().parent().fadeIn(300);
});
});
It works great in Opera, IE (7,8) and Chrome but in firefox. 它在Opera,IE(7,8)和Chrome浏览器中效果很好,但在Firefox中效果很好。 The keyUp event fires as expected (also in firefox) but no thumbs gets hidden. keyUp事件会按预期触发(也在firefox中触发),但不会隐藏任何拇指。 Firebug logs no errors in the console. Firebug在控制台中未记录任何错误。
Any help would be appreciated Thanks in advance \\JePpE 任何帮助将不胜感激预先感谢\\ JePpE
As a workaround you can use the filter
function and code the criteria manually: 解决方法是使用filter
功能并手动编码条件:
$(".title").filter(function() { return $(this).html().indexOf(searchString) < 0; })
.each (...);
Should work under any browser. 应该可以在任何浏览器下工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.