Home Ask Login Register

Developers Planet

Your answer is one click away!

gopre400 February 2016

find on page/element widget javascript

Is there a widget or function in javascript that duplicates functionality of browser "Find on Page?" I want user to type in to search input, which then finds each occurrence of value and highlights. Also includes found # of # with next and previous buttons. It would be great if there were a widget. If not maybe function to find multiple occurrences of string?

Find on Page


Shubham Dubey February 2016

You can Use Window.find to search for any element on page. Basically you are searching in the DOM and Window is the parent object.

<form action=""  id="form2">
<input type="text" id="search">
<input type="button" id="submit_form" onclick="checkInput()" value="Submit">

function checkInput() {  
var query =document.getElementById('search').value;  
return true;

Arun Sharma February 2016

Check this. Required strings have been underlined.

<!doctype html>

contains demo

John Resig George Martin Malcom John Sinclair J. Ohn $( "div:contains('John')" ).css( "text-decoration", "underline" );

Post Status

Asked in February 2016
Viewed 2,813 times
Voted 5
Answered 2 times


Leave an answer

Quote of the day: live life