I have a string such as:
http://www.google.com/#anchor-name
and I want to be able to get
http://www.google.com/
and
anchor-name
into variables? How do I do it geniuses of the stackoverflow community?
I have a string such as:
http://www.google.com/#anchor-name
and I want to be able to get
http://www.google.com/
and
anchor-name
into variables? How do I do it geniuses of the stackoverflow community?
In your situation
var str = "http://www.google.com/#anchor-name";
var parts = str.split('#');
console.log(parts)//["http://www.google.com/","anchor-name"]
Try
var parts = str.split('#');
var left = parts[0], right = parts[1];