Find substring with Jquery?

javascript, jquery

Solution

You don't really need jQuery for such a simple thing, you can simply use the `indexOf` method of String objects, e.g.:

var str = "foobar";
var containsFoo = str.indexOf('foo') >= 0; // true

The `indexOf` method returns the character index where the first occurrence of the specified value is encountered, if not found, it returns `-1`.

Problem

How would our group find out if a particular string contains a certain substring? Only with the help of jquery, please.

Original source