简体   繁体   English

:contains()在Opera,IE(7,8)和Chrome中工作正常,但在Firefox中工作正常

[英]: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.

相关问题 Javascript / jQuery无法在Firefox,Safari和IE中运行。 精通Opera和Chrome - Javascript/jQuery not working in Firefox, Safari and IE. Fine in Opera and Chrome jQuery AJAX在任何IE中均不起作用,但在Firefox,Opera,Chrome和Safari中运行良好 - jQuery AJAX not working in any IE, but fine in Firefox, Opera, Chrome and Safari JavaScript无法在IE和Firefox中运行,在Chrome中运行良好 - JavaScript not working in IE and Firefox, works fine in Chrome 该功能适用​​于Chrome,但在IE和Firefox中无法正常运行 - Function works fine with chrome but not in IE and Firefox 此代码适用于Chrome,Firefox但不适用于IE - This code works fine in Chrome, Firefox but not in IE 加载的内容在Ajax .load()之后丢失charset(UTF-8),但仅在FireFox和IE中。 Chrome和Opera可以正常运行 - Loaded content loses charset(UTF-8) after Ajax .load(), but only in FireFox and IE. Chrome and Opera works fine Jplayer音频不能在Firefox,Opera和IE中运行,但可以在Chrome中使用 - Jplayer audio not working in firefox, opera and IE but works in Chrome 该Javascript在IE中不起作用,但在Chrome,Firefox和Opera中起作用 - This Javascript doesn't work in IE but works in Chrome, Firefox and Opera jQuery代码可在Firefox,Opera中使用,但不能在Chrome和IE中使用 - JQuery Code works in Firefox, Opera but not working in Chrome and IE 将HTML插入iframe在Firefox / Chrome / Opera中有效,但在IE7 / 8中则无效 - Inserting HTML to iframe works in Firefox/Chrome/Opera but not in IE7/8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM