How to make a live page search among all links in native JS?

  • 0
    Hello everyone, I solve a problem, I am learning to develop in JS, you need to create a search, the result in the form of a drop-down list and highlight the found elements.


    While I was able to implement the search for the desired element and hide the rest. Tell me how to solve the problem completely.
    my code
    JavaScript Owen Frazier, May 6, 2020

  • 2 Answers
  • 0
    learning to develop in JS


    tell me how to solve the problem completely


    Great start, keep it up. Seriously, you've written 10 lines of code and you're done with ideas?



    But it's not difficult to tell: you go to the wiki, use the search, press f12 and see how the display is implemented there. You copy. Truncated.
    Anonymous

  • 0
    Next, to highlight you need:


    1. get length let pos = value.length;

    2. in your forEach loop, take a substring from elem from 0 to pos in a match condition and write it to the variable

    3. wrap the value of this variable in span

    4. take a substring from elem from pos to the end of the line and write to the variable

    5. add these two variables and assign elem

    6. add to css a & gt; span {background: yellow}

    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!