trim string after - in jquery 1

trim string after – in jquery

var str = "example.com/hello#item1".split('#')[0];

Here is what the above code is Doing:
1. We’re using the split() method to split the string into an array of substrings.
2. We’re using the array index to get the first item in the array.
3. We’re assigning the first item in the array to a variable.

Similar Posts