How to remove last text after / from location.href using jQuery?

Solution:

Replace the line of code var url_id_value = url_id.split('#')[1]; with the following:

var url_id_value = url_id.substr(0, url_id.lastIndexOf("/") + 1);