trim string after - in jquery code example Example: trim string after - in jquery var str = "example.com/hello#item1".split('#')[0];