I am using iScroll Lite base on iScroll v4.1.6
in my project and this scrolling is working perfectly fine. My structure for iscroll is given below:
<article id="contentWrapper">
<div id="contentScroller">
<table cellpadding="0" cellspacing="0" width="100%">
<TBODY>
<tr class="datatable_row" id="1">
<td width="10%">13/02/2013</td>
<td class="narration" width="28%">Chq paid</td>
</tr>
<tr class="datatable_row" id="2">
<td>16/02/2013</td>
<td class="narration">Chq paid</td>
</tr>
</TBODY>
</table>
</div>
</article>
And the Javascript code for Iscroll apply is given below:
var scrollContent;
function loaded() {
scrollContent = new iScroll('contentWrapper');
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', loaded, false);
Now you can see that there are so many <tr>
elements in my table which are coming dynamically having an id. Now suppose I want to scroll to <tr>
which has id 7 . How can I do this?
I tried the following, but it's not working:
scrollContent.scrollToElement("#7", "1s");
Giving error in console, which is:
Uncaught SyntaxError: Failed to execute query: '#7' is not a valid selector.
Please let me know how to scroll to a particular id using Iscroll.