I use tables in my document, and I want the user to be able to send a new item to the list, and then "automatically" appear at the top of the list (yes, that would be easier with the DIV, but working with what I have) .
I use jQuery clone()to create a copy of the last row of the table, and then use fadeIn()to display a new item after updating and adding it to the top of the list. Since internally jQuery converts the elements (assuming a DIV) to "block", I also change the css class to "table-row". It works great.
All code is here:
var row = $("tbody tr:first").clone().hide();
row.children("td[class=td-date]").html("today");
row.children("td[class=td-data]").html("data");
row.children("td[class=td-type]").html("type");
row.insertBefore("tbody tr:first").stop().fadeIn(2000).css("display","table-row");
The problem is that if I started the process too fast - that is, before fadeIn is completed, the clone () command also clones the opacity.
I can get it working in Firefox using the first line setting above:
var row = $("tbody tr:first").clone().css("opacity","1").hide();
Now I'm worried that I'm not sure that all this is being done efficiently and / or that "opacity" is a cross-browser that you can rely on.
Has anyone done something similar before and can offer any pointers to a more robust approach?
Filmj source
share