I am working with ASP.net and C#
I have a GridView with Multiple rows. I have a text box and search button. My grid columns are Id and name. If I type a name in the text box and click search button. I have highlighted the names in the grid which I typed in the textbox and must scroll to the highlighted row.
How can I search and Highlight it but cannot scroll to the selected row?
Try below function
function scrollToElement(selector, time, verticalOffset) {
time = typeof(time) != 'undefined' ? time : 500;
verticalOffset = typeof(verticalOffset) != 'undefined' ? verticalOffset : 0;
element = $(selector);
offset = element.offset();
offsetTop = offset.top + verticalOffset;
$('html, body').animate({
scrollTop: offsetTop
}, time);
}
Call this function like scrollToElement('elementUniqueIdHere`, 750, -50);
Hope this helps you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.