You don't need to use .contains()
. The .indexOf()
method returns the index at which the matching text starts, or -1 if the text isn't found. So you can change
$(this).text().toLowerCase().indexOf(alString) == 0;
to this:
$(this).text().toLowerCase().indexOf(alString) > -1;
The bolding will be a bit more complex. Every time a key is pressed, you'll need to iterate all the items and unwrap
any b
tags. Then for each item to be shown, I would probably just use a regex to replace the search text with the same text wrapped in b
tags.