Javascript 基于选择器的jquery切换(显示/隐藏)

Javascript 基于选择器的jquery切换(显示/隐藏),javascript,jquery,css,css-selectors,Javascript,Jquery,Css,Css Selectors,我想创建基于jquery的动画,下面是我的代码 >items=document.querySelectorAll("#customers td span"); [<span alt=​" 02,Counter,11,2013-04-06 14:​59:​16">​ 02​</span>​, <span>​11​</span>​, <span alt=​" 02,Counter,11,2013-04-06 13:​22:​19"&g

我想创建基于jquery的动画,下面是我的代码

>items=document.querySelectorAll("#customers td span");
[<span alt=​"  02,Counter,11,2013-04-06 14:​59:​16">​  02​</span>​, <span>​11​</span>​, <span alt=​"  02,Counter,11,2013-04-06 13:​22:​19">​  02​</span>​, <span>​11​</span>​]
>item=items[0]; // it has a parent tag <tr> i want the whole row to blink (both spans)
<span alt=​"  02,Counter,11,2013-04-06 14:​59:​16">​  02​</span>​
>tm=item.attributes.getNamedItem("alt");
alt=​"  02,Counter,11,2013-04-06 14:​59:​16"
>dtm=tm.value.split(',')[3];
"2013-04-06 14:59:16"
每秒钟我都要检查项目中的每个元素;如果dtm>当前时间-10秒,则应在500毫秒后隐藏,并在500毫秒后显示

我上面的代码只会闪烁一个范围,我希望两个元素都闪烁。。这个检查应该每1秒继续一次

有人能帮我吗


谢谢..

以下是我的最终代码

<script>
$(document).ready(function ($) {
    window.setInterval(function(){
        $("#customers, td, span").each(function(){
            if($(this).children("span").attr("alt")!=null){
                var dt=new Date($(this).children("span").attr("alt").split(",")[3].replace(/-/g,"/")).getTime();
                if(dt>$.now()-20*1000){
                    console.log("animating");
                    $(this).parent().fadeOut(500,"linear");
                    $(this).parent().fadeIn(500,"linear");
                }
            }
        });
    },1100);
});
</script>

$(文档).ready(函数($){
setInterval(函数(){
$(“#客户,td,span”)。每个(功能(){
if($(this).children(“span”).attr(“alt”)!=null){
var dt=new Date($(this).children(“span”).attr(“alt”).split(“,”[3]。replace(/-/g,“/”).getTime();
如果(dt>$.now()-20*1000){
console.log(“动画”);
$(this.parent().fadeOut(500,“线性”);
$(this.parent().fadeIn(500,“线性”);
}
}
});
},1100);
});

如果您能够使用jQuery,为什么要乱搞
querySelectorAll
属性。getNamedItem()
?您需要遍历项目,因此
$(“#customers td span”)。每个(…
应该负责循环,然后
$(此)。attr(“alt”)
获取带有当前项目日期的属性。问题是如何将日期作为字符串(在
拆分()之后)
)并将其转换为实际日期以与当前时间进行比较?我已经这样做了,现在的问题是动画的流畅性..上面的代码在chrome中运行,但在firefox中没有..有人能帮忙吗?添加了
-webkit transform:translateZ(0)
#客户、td、span、tr
,这稍微提高了动画的性能。。
<script>
$(document).ready(function ($) {
    window.setInterval(function(){
        $("#customers, td, span").each(function(){
            if($(this).children("span").attr("alt")!=null){
                var dt=new Date($(this).children("span").attr("alt").split(",")[3].replace(/-/g,"/")).getTime();
                if(dt>$.now()-20*1000){
                    console.log("animating");
                    $(this).parent().fadeOut(500,"linear");
                    $(this).parent().fadeIn(500,"linear");
                }
            }
        });
    },1100);
});
</script>