I want to apply right alignment for all the columns except for the first column.
I wrote the following, but which is working fine. But how can i combine these to statements in to one line.
$("table.ftable tr:gt(0)").css("text-align", "right开发者_高级运维");
$("table.ftable td:first-child").css("text-align", "left");
Any Ideas..?
try using CSS in a style sheet. avoid js to css at all costs if you can!.. an accumulation of these will make your app slower.
http://jsfiddle.net/KCb4K/2/
table td {
text-align:right;
}
table tr td:first-child {
text-align: left !important;
}
http://www.w3schools.com/cssref/sel_firstchild.asp
Try this :
$("table td:first").css("text-align", "left");
table.ftable tr:nth-child(n+1);
Here it is:
$(".ftable td:gt(0)").css("text-align", "right");
http://jsbin.com/ivegoh/edit
精彩评论