Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pass the search result to scrollIntoView

See original GitHub issue

I am keen to pass the search result (if find any) to the scrollIntoView function in jQuery.

I use the code below for the search:

   $input.on("input", function () {
            var searchVal = this.value;
                done: function () {
                    $content.mark(searchVal, {
                        "wildcards": "disabled",
                        "accuracy": "exactly",
                        "iframes": true,
                        "ignoreJoiners": false,
                        "acrossElements": true,
                        "separateWordSearch": false,
                        done: function () {
                            $results = $content.find("mark");
                            currentIndex = 0;

here the function jumpTo() is defined as

   function jumpTo() {
            if ($results.length) {
                var position,
                    $current = $results.eq(currentIndex);
                if ($current.length) {
                        block: 'center',
                        inline: 'center'

but it does not work and instead gives me the error below: 19:1380 Uncaught TypeError: $results.scrollIntoView is not a function

I further require the search scrolls to elements one by one if there are more than one results.

Please can you help?

Than you very much for your time.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

Mottiecommented, Jun 18, 2020

Try this -

That demo had some weird quirks; but the main point is that scrollIntoView requires a DOM element, not a jQuery element.

$current[0].scrollIntoView({ ... });
omidMolaverdicommented, Jun 18, 2020

Hi @julmot. Please can kindly you take a look at this ticket?

Read more comments on GitHub >

github_iconTop Results From Across the Web

scrollIntoView Scrolls just too far - Stack Overflow
The issue is that it goes just a tad too far. Like the option they are on is about 10px too high. So,...
Read more >
How to Scroll into view in Selenium Webdriver
It was a little challenging to scroll for each element. In Selenium we can do this with scrollIntoView(true) which can scroll automatically till ......
Read more >
Element.scrollIntoView() - Web APIs | MDN
The Element interface's scrollIntoView() method scrolls the element's ancestor containers such that the element on which scrollIntoView() is ...
Read more >
scrollIntoView - Cypress Documentation
scrollIntoView () can time out waiting for assertions you've added to pass. Command Log. Assert element is visible after scrolling it into view....
Read more >
Scrolling a React Element into View | Building SPAs
This method will scroll the element's parent container so that it becomes visible to a user. Nice! Using scrollIntoView in React. How do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found