I am trying to replace the last slash in a series of URL strings in order to swap this slash for a number sign, for example:
http:
to
http://example.com/about
Using JS with jQuery I tried applying the replace function to each row, but am not sure how to target only the last slash.
$('.submenu a').each(function() {
var url = $(this).attr('href');
url = url.replace(/\//g, '#');
console.log(url);
});
source
share