1

水平スクロールを持つ指定された幅の div 内にこのテーブルがあります。

<div id="content">
<table class="tbclass">
<tr>
    <th>h1</th>
    <th>h2</th>
    <th>h3</th>
    <th>h4</th>
    <th>h5</th>
    <th>h6</th>
    <th>h7</th>
    <th>h8</th>
</tr>
<tr>
    <td><input type="text" name="inputname1" id="inputid1" /></td>
    <td><input type="text" name="inputname2" id="inputid2" /></td>
    <td><input type="text" name="inputname3" id="inputid3" /></td>
    <td><input type="text" name="inputname4" id="inputid4" /></td>
    <td><input type="text" name="inputname5" id="inputid5" /></td>
    <td><input type="text" name="inputname6" id="inputid6" /></td>
    <td><input type="text" name="inputname7" id="inputid7" /></td>
    <td><input type="text" name="inputname8" id="inputid8" /></td>
</tr>
</table>

input id="inputid4"ページがロードされた後、 jqueryを使用した例で特定の入力にスクロールしたい. 私はjqueryで実装されたscrolltoを見ていますが、要素のインデックスを使用する例があり、インデックスの代わりに特定のIDでそれを使用する方法がわかりません.

4

2 に答える 2

1

scrollTo プラグインを使用できます

http://demos.flesler.com/jquery/scrollTo/

divまたははtableスクロール可能ですか? 次のようなものを試してください:

$('#content').scrollTo($("#inputid4"));

また

$('.tbclass').scrollTo($("#inputid4"));
于 2011-03-17T09:55:11.377 に答える
1

または、要素のインデックスを取得して scrollTo に渡します

$("#content").scrollTo($("#inputid4").index());
于 2011-03-17T10:05:57.253 に答える