jQuery :not() Selector iOS5 compatible?

jQuery :not() Selector iOS5 compatible?

本文关键字:iOS5 compatible Selector not jQuery      更新时间:2023-09-26

我在客户端wordpress博客中使用以下jQuery块:

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

这段代码淡化了父容器(this),但不会像我希望的那样淡化.previewTitle.previewBody的两个内部容器。此代码适用于除iOS (5) Safari以外的所有主要浏览器版本 - 有人知道为什么iOS对我有牛肉吗?

谢谢!

编辑:我检查了几次你的测试代码,但我真的看不出有什么区别。这是我的完整代码:

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();
                    });
                }
            });

你不会把参数放在引号里:not,只是:

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

:not接受选择器,而不是字符串。我很好奇它适用于其他带有引号的浏览器......

除此之外,它应该可以工作。它在iOS 4.3.2(我妻子的iPad)上对我有用:实时副本|源

.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:

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

。但我没有方便测试的iOS 5。


旁注:

这段代码淡化了父容器(this),但不会像我希望的那样淡化.previewTitle.previewBody的两个内部容器。

您引用的代码根本不会淡化父容器。它会淡化除列出的两个子项之外的所有子项。那不是一回事。