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