Select All 'Tr' Except the First One

Select all 'tr' except the first one

By adding a class to either the first tr or the subsequent trs. There is no crossbrowser way of selecting the rows you want with CSS alone.

However, if you don't care about Internet Explorer 6, 7 or 8:

tr:not(:first-child) {
color: red;
}

Select all except first and last td element in one selector

It is syntactically correct, as you can quickly check using the W3C CSS Validator. The validator is known to have errors, so in principle, you should check the rule against CSS specifications, especially Selectors Level 3. The result is still that yes, it is correct.

It also has the desired meaning, since this is how selectors combine. You can use :not(...) selectors to express a condition of type “not ... and not ...”.

This applies provided that all children of tr elements are td. If there are header cells, i.e. th elements as well, then the selector applies to those data cells (td elements) that are not the first data cell or the last data cell in a row with .red class.

Jquery- Hiding all tr except the first one

You can exclude the first element using .not() method:

$('table tbody tr').not(':first').hide();

And for selecting the next hidden tr element you can use .nextAll() and :hidden selector:

var $row = $this.closest("tr").nextAll(':hidden').first();

Select all tr except last and first ones with .on()

:first and :last match the first and last element in the jQuery object. Since you're using on(), that selector will be evaluated in the context of a jQuery object containing a single element (the event target). Therefore, that element will never be matched, as it is both the first and last item in the set.

Contrast :first-child and :last-child, which match the first and last element in the parent element. Using them should solve your problem:

$("#id").on("click", "td:not(:first-child, :last-child)", callback);

jquery - get all rows except the first and last

Drop the gt(), as I'd assume it's a tiny bit slower than :first.

Use not() in conjunction with :first and :last:

$('table#tbl > tbody > tr').not(':first').not(':last').addClass('highlight');

Most browsers automatically add an tbody element in the table markup if that's missing, that is why the immediate children selector was failing – there were no <tr> elements as an immediate children to the <table> tag.

I am not 100% sure this is the way all browsers do it, so it would be safer to just add the <tbody> manually. Otherwise you need a little sniffing and cannot do it as an one liner:

if($('table#tbl > tbody').size() > 0) {
$('table#tbl > tbody > tr').not(':first').not(':last').addClass('highlight');
} else {
$('table#tbl > tr').not(':first').not(':last').addClass('highlight');
}

Hope this solves your problem!

jQuery How to get the all rows HTML except first?

Because html method returns the html contents of the first matched element.

Get the HTML contents of the first element in the set of matched elements.

You can use the each() method, try this:

$('#files-table> tbody > tr').not(':first').each(function(){
console.log($(this).html())
})

Fiddle

You can define a variable and store the html contents of the matched elements:

var html = '';

$('#files-table> tbody > tr:not(":first")').each(function(){
html += $(this).html()
})

Select all children except first one of element

Use :not(:first-child) to exclude the first link