Javascript - Search and highlight text in document

Rashida
Rashida saved this snippet as JavaScript
Discussion
alberto 1 year ago If you push the search button with empty box, it will change the page content "<p>JavaScript is the programming language of the Web. The overwhelming majority of modern websites use JavaScript, a ecc.."
Rashida 1 year ago Hi, thanks for letting me know! I have updated the javascript to include a small if function checking if the user has entered a value in the textfield and then carrying out the search or if the textfield was left empty informing the user to enter a value. This also resolves the problem with additional HTML codes being added to the pages content.

Leave A Reply


You may use these HTML tags and attributes:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strong>