The indexOf() method searches a string for a match!!!!!


This code will find every occurrence of a Locate string in a Search String and
show a list of where it was located and the the values around those finds.

This is NOT case Sensitive

This function loads a paragraph type with id's p1, p2, p3 if you choose to pass it a true for display.
and returns an array of 2 arrays, [0] are all the locations found, [1] are all the surrounding text which you can see in the the alert that pops up.

The calling HTML should have the return paragraph id's of p1, p2, p3
and
input elements id: userInput, userLookFor

Enter some text you would like to Search and text to Locate:

Text to Search:


Where it was located

=== In Array Format ====

==== Surrounding Text ===