Issue On Scrolling to A Row in Table
Can you please take a look at this DEMO and let me know how I can use jQuery to scroll to the selected row or animate that row to the middle of the scrolled div sc?
Here is the code:
- <div id="sc">
- <table id="mytable"></table>
- </div>
- <button class="25">Scrool to 25</button>
- <button class="75">Scrool to 75</button>
- <button class="125">Scrool to 125</button>
- <button class="199">Scrool to 199</button>
- <button class="0">Scrool to 0</button>
- <script>
- $(document).ready(function () {
- for (var i = 0; i < 200; i++) {
- $('#mytable').append('<tr class=' + i + '><td>This is Row' + i + ' </td></tr>');
- $("#125").click(function() {
- $('#sc').animate({
- scrollTop: $("#sc").offset().top}, 2000);
- });
- }
- });
- <script>
Thanks alot