如何使用javascript / jquery关注给定表的行? [英] How can I focus on a given table's row using javascript/jquery?

查看:66
本文介绍了如何使用javascript / jquery关注给定表的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个大的html表,其中有许多行不适合屏幕,你知道如何使用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?

推荐答案

查找scrollIntoView函数。通过(我认为)所有浏览器支持大多数元素。

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

当我想制作一个表(或者像表格之类的东西)时,我做了什么,我确保目标表行有一个特殊的类,或者可能是id值。然后我可以使用Javascript找到该行并调用scrollIntoView()。你唯一需要注意的是,IE有时会混淆并搞砸桌子周围的布局,但是如果你小心设置可滚动元素,通常可以使它工作。

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.

这篇关于如何使用javascript / jquery关注给定表的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆