O'Reilly logo

PHP jQuery Cookbook by Vijay Joshi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching for user-inputted string in a page

We will use jQuery to highlight a word entered by the user. The data on the browser can be made available from the server side (or database) as well. For this example, we will use some text in an HTML page. The user will enter a search query in a textbox and after pressing a button all matching words in the content will be highlighted.

Getting ready

Create a folder for this recipe in the Chapter5 directory and name it as Recipe2.

How to do it...

  1. Open a new file, name it as index.html and save it in the Recipe2 folder. Let us begin by writing the markup now. Create some paragraphs and put some text inside them. In the end, place a textbox and two buttons. We have also defined a CSS class highlight that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required