I am looking to implement a jQuery-based animation and here is the code I have so far:
>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"
Alternatively 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);
});
My goal is to check each element in items every second. If dtm is greater than current time - 10 seconds, then hide after 500 ms and show after 500ms.
However, the current code only blinks one span and I need both elements to blink. This check should continue every 1 second.
If anyone can assist me with this, I would greatly appreciate it.
Thank you!