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