开发者

jQuery selector for all the cols except the first col on a table

开发者 https://www.devze.com 2023-04-04 22:13 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消