gpt4 book ai didi

javascript - jQuery :not() Selector iOS5 compatible?

转载 作者:行者123 更新时间:2023-11-28 20:35:05 25 4
gpt4 key购买 nike

我在我的客户 wordpress 博客中使用了以下 jQuery block :

  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):Live copy | source

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 code fades the parent container (this), but not the two inner containers .previewTitle and .previewBody as I would like.

您引用的代码根本不会淡化父容器。除了列出的两个,它会淡出所有。这不是一回事。

关于javascript - jQuery :not() Selector iOS5 compatible?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10851690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com