Reputation: 271
I am trying to append some extra rows to my table, but can't make it fancy with fadein(). As you can see mine is applying the fade in effect to the very first row.
How can I apply the fadein to my other 3 rows??
I switched the places of the methods, but no success
$("input").click(function () {
$("table tr:last")
.hide()
.after("<tr><td>SecondRow</td></tr><tr><td>ThirdRow</td></tr><tr><td>ForthRow</td></tr>")
.fadeIn(1000);
});
Upvotes: 3
Views: 205
Reputation: 144699
$("input").click(function(){
$("<tr><td>SecondRow</td></tr><tr><td>ThirdRow</td></tr><tr><td>ForthRow</td></tr>")
.hide()
.insertAfter("table tr:last") // .appendTo("table tbody")
.fadeIn(1000);
});
Upvotes: 3
Reputation: 2005
Try this:
$("input").click(function () {
var rows = $("<tr><td>SecondRow</td></tr><tr><td>ThirdRow</td></tr><tr><td>ForthRow</td></tr>");
rows.css({
display: 'none'
});
$("table tr:last").append(rows);
rows.fadeIn(1000);
});
You can combine these two statements:
var rows = $("<tr><td>SecondRow</td></tr><tr><td>ThirdRow</td></tr><tr><td>ForthRow</td></tr>");
rows.css({
display: 'none'
});
to
var rows = $("<tr class=\"display: none\"><td>SecondRow</td></tr><tr><td>ThirdRow</td></tr><tr><td>ForthRow</td></tr>");
Upvotes: 3