Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

jquery toggle (show/hide) based on selector

jquery toggle (show/hide) based on selector

Problem

I want to create animation based on Jquery, below is my code;

>items=document.querySelectorAll("#customers td span");
[​  02​​, ​11​​, ​  02​​, ​11​​]
>item=items[0]; // it has a parent tag  i want the whole row to blink (both spans)
​  02​​
>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"


or in JQuery:

$(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]).getTime();
                    if(dt>$.now()-10*1000){ //am i right here??
                        console.log("animating");
                        $(this).parent().fadeOut("slow");
                        $(this).parent().fadeIn("slow");
                    }        
       });
    },1000);
});

every second i want to check for each element in items; if dtm > current time - 10 seconds, then it should hide after 500 ms and should show after 500ms.

the code above that i have will only blink one span, i want both of the elements to blink.. and this check should continue each 1 second.

can any one help me..

Thanks..

Problem courtesy of: Fayyaz Ali

Solution

Below is my final code;

Solution courtesy of: Fayyaz Ali

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

jquery toggle (show/hide) based on selector

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×