jQuery scrollTo
i have this table inside an div with specified width that has horizontal scroll.
<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" />开发者_C百科;</td>
<td><input type="text" name="inputname7" id="inputid7" /></td>
<td><input type="text" name="inputname8" id="inputid8" /></td>
</tr>
</table>
after page is loaded i want to scroll to a specific input by example input id="inputid4"
using jquery. i look over scrollto implemented in jquery but there are the example using the index of the element and i don't know how to use it with a specific id instead of index.
You could use the scrollTo plugin
http://demos.flesler.com/jquery/scrollTo/
Is the div
or table
scrollable? Try something like:
$('#content').scrollTo($("#inputid4"));
or
$('.tbclass').scrollTo($("#inputid4"));
Or, get the index of the element and pass it to scrollTo
$("#content").scrollTo($("#inputid4").index());
精彩评论