Would this work as well?

$("tr:not(:first):not(:last)").hover(function() { //etc.

Not as performant as the other ones, but expresses the intent clearly.

-- Josh


----- Original Message ----- From: "Karl Swedberg" <[EMAIL PROTECTED]>
To: <jquery-en@googlegroups.com>
Sent: Thursday, June 26, 2008 11:15 AM
Subject: [jQuery] Re: Adding hover to all table rows (tr) but the first one.



Hi again,

you replied directly to me with this:

Awesome! Now 1 more question.

How can I have it not hover the last row too?

Hope you don't mind that I'm posting a response to this question on the list. I'd like other people to be able to see the answer as well, just in case someone else might have the same question later on...

Instead of using :gt(0) within the selector expression, you can use the slice method -- .slice(1,-1)

So it would look like this:

$('tr').slice(1, -1).hover(function() {
 // Stuff to do when the mouse enters the row;
}, function() {
 // Stuff to do when the mouse leaves the row;
});

Cheers,

--Karl

On Jun 26, 2008, at 12:23 PM, Karl Swedberg wrote:


Hi,

you should be able to do it like so:


$('tr:gt(0)').hover(function() {
 // Stuff to do when the mouse enters the row;
}, function() {
 // Stuff to do when the mouse leaves the row;
});


--Karl
____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Jun 26, 2008, at 11:27 AM, aldomatic wrote:


I'm having a difficult time figuring out how to add a hover effect on
all but the first table row (tr).

I appreciate anyone's help.

Thanks!



Reply via email to