开发者

Get only from second TR to last from table

开发者 https://www.devze.com 2023-04-09 23:45 出处:网络
i have a variable $response and in it i have object of a table the table has ID i\'m trying to have the variable only with the TR (no TABLE tag or /Table tag) and the TD content

i have a variable $response and in it i have object of a table

the table has ID

i'm trying to have the variable only with the TR (no TABLE tag or /Table tag) and the TD content

i have tried:

$response = $response.find('#gGridView1');
$response = $response.find('tr').slice(1);

and

$response = $response.find('#gGridView1');
$response = $response.find('tr:first').remove();

i have fixed my first quesiton

the answer is:

$response = $response.find('#gGridView1');
$response.find('tr:first').remove();

in addition, what would be the way without each or loop to have every TD in 开发者_StackOverflow中文版the table that is the second column to have a specific width of 100px?


I believe you are looking for the nth-child selector:

http://api.jquery.com/nth-child-selector/

So for example, something like:

$response.find('td:nth-child(2)').css('width','100px');


To get every tr that is not the first, just select everyone that is not the first:

$response = $response.find("#table tr:not(:first)");

For the second td of every tr use the nth-child selector:

$response = $response.find("#table tr td:nth-child(2)");

0

精彩评论

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