I'm currently capturing the URL as follows:
$(this).attr('href')
Let's suppose that the URL is: http: /teste.com/login
How do I capture only the end: / login
I'm currently capturing the URL as follows:
$(this).attr('href')
Let's suppose that the URL is: http: /teste.com/login
How do I capture only the end: / login
If you want to get only the last string ('login') you can use the split ('/') property that will transform the URL into an array based on the '/' used by it, You can get the last position of this array.
var URL = 'http://teste.com/login';
var URLArr = URL.split('/'); // ["http:", "teste.com", "login"]
var URLPath = URLArr[URLArr.length -1]; // "login"
Or,
You can use replace
$(this).attr('href').replace(/^.*\/\/[^\/]+/, '');