簡體   English   中英

jQuery:not()選擇器iOS5兼容嗎?

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

我在客戶的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

您引用的代碼根本不會淡化父容器。 它會淡出除列出的兩個元素之外的所有元素。 那不是同一回事。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM