SyntaxFix
Write A Post
Hire A Developer
Questions
You can also use the split() function. This seems to be the easiest one that comes to my mind :).
split()
url.split('?')[0]
jsFiddle Demo
One advantage is this method will work even if there is no ? in the string - it will return the whole string.
?