如何使用 jQuery 滾動到特定項目? - How to scroll to specific item using jQuery?

問題:

I have a big table with vertical scroll bar.我有一個帶有垂直滾動條的大桌子。 I would like to scroll to a specific line in this table using jQuery/JavaScript.我想使用 jQuery/JavaScript 滾動到此表中的特定行。

Are there built-in methods to do this?是否有內置方法可以做到這一點?

Here is a little example to play with.這是一個可以玩的小例子。

div { width: 100px; height: 70px; border: 1px solid blue; overflow: auto; }
<div> <table id="my_table"> <tr id='row_1'><td>1</td></tr> <tr id='row_2'><td>2</td></tr> <tr id='row_3'><td>3</td></tr> <tr id='row_4'><td>4</td></tr> <tr id='row_5'><td>5</td></tr> <tr id='row_6'><td>6</td></tr> <tr id='row_7'><td>7</td></tr> <tr id='row_8'><td>8</td></tr> <tr id='row_9'><td>9</td></tr> </table> </div>


解決方案:

參考一: https://stackoom.com/question/CBwp
參考二: How to scroll to specific item using jQuery?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章