systempuntoout
systempuntoout

Reputation: 74064

How can I focus on a given table's row using javascript/jquery?

Having a big html table with many rows that does not fit on the screen, do you know how to focus on a given row with javascript/jquery avoiding the need to scroll down?

Upvotes: 0

Views: 1633

Answers (1)

Pointy
Pointy

Reputation: 413702

Look up the "scrollIntoView" function. It's supported on most elements by (I think) all the browsers.

What I do, when I want to make a table (or something like a table) behave that way, I make sure that the target table row has a special class, or maybe an "id" value. Then I can find the row with Javascript and call "scrollIntoView()". The only thing you have to watch out for is that sometimes IE gets confused and screws up layout around the table, but if you're careful with how you set up scrollable elements it usually can be made to work.

Upvotes: 2

Related Questions