简体   繁体   English

jQuery:not()选择器iOS5兼容吗?

[英]jQuery :not() Selector iOS5 compatible?

I am using the following block of jQuery in my clients wordpress blog: 我在客户的wordpress博客中使用以下jQuery块:

  jQuery(this)
      .children(":not('.previewTitle, .previewBody')")
      .fadeTo(fadeTime, activeOpacity, function(){
      //some code
});

This code fades the parent container (this), but not the two inner containers .previewTitle and .previewBody as I would like. 这段代码使父容器(this)褪色,但不会像我想要的那样使两个内部容器.previewTitle.previewBody This code works in all major browser versions except iOS (5) Safari - does anyone have any idea why iOS has beef with me? 该代码可在除iOS(5)Safari之外的所有主要浏览器版本中使用-有人知道为什么iOS与我同在吗?

Thanks! 谢谢!

EDIT: Ive checked your test code over a few times, but I really cannot see a difference. 编辑:我已经检查了您的测试代码几次,但我确实看不出有什么区别。 Here is my full code: 这是我的完整代码:

jQuery(thumbs).hover(
            function(){
                jQuery(this).children(":not(.previewTitle, .previewBody)").fadeTo(fadeTime, activeOpacity, function(){
                    //Display Preview Body once faded in
                    strId = jQuery(this).closest('div').attr('id'); //Get parent DIV ID
                    jQuery('#previewTitle' + strId.substr(9)).show();
                    jQuery('#previewBody' + strId.substr(9)).show();
                });
            },
            function(){
                // Only fade out if the user hasn't clicked the thumb
                if(!jQuery(this).hasClass(clickedClass)) 
                {
                    //Fade out of thumbnail..
                    jQuery(this).children(":not(.previewTitle, .previewBody)").fadeTo(fadeTime, inactiveOpacity, function(){
                        //Hide Preview Body once faded out
                        strId = jQuery(this).closest('div').attr('id'); //Get parent DIV ID
                        jQuery('#previewTitle' + strId.substr(9)).hide();
                        jQuery('#previewBody' + strId.substr(9)).hide();
                    });
                }
            });

You don't put the argument to :not in quotes, just: 您不要将参数放在:not引号中,而只需:

jQuery(this).children(":not(.previewTitle, .previewBody)").fadeTo(....
//            no quote ----^              no quote ----^

:not accepts a selector , not a string. :not接受选择器 ,而不是字符串。 I'm intrigued it works on other browsers with the quotes... 我很感兴趣它可以在其他浏览器上使用引号...

Other than that, it should work. 除此之外,它应该工作。 It works for me on iOS 4.3.2 (my wife's iPad): Live copy | 它适用于我在iOS 4.3.2(我妻子的iPad)上的实时复制 | source 资源

HTML: HTML:

<p>Click anywhere in the shaded container:</p>
<div id="container">
  <p>Child that will fade</p>
  <p>Another that will fade</p>
  <p class="previewTitle">previewTitle - won't fade</p>
  <p>Another that will</p>
  <p class="previewBody">previewBody - won't fade</p>
  <p>Another that will</p>
</div>

JavaScript: JavaScript:

jQuery(function($) {

  $("#container").click(function() {
    $(this)
      .children(":not('.previewTitle, .previewBody')")
      .fadeTo("slow", "0.2");
  });

});

...but I don't have iOS 5 handy to test. ...但是我没有可方便测试的iOS 5。


Side note: 边注:

This code fades the parent container (this), but not the two inner containers .previewTitle and .previewBody as I would like. 这段代码使父容器(this)褪色,但不会像我想要的那样使两个内部容器.previewTitle.previewBody

The code you've quoted doesn't fade the parent container at all. 您引用的代码根本不会淡化父容器。 It fades all of its children except the two listed. 它会淡出除列出的两个元素之外的所有元素。 That's not the same thing. 那不是同一回事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM