javascript - Remove the latest URL parameter after "/" -
i need remove text (or parameters) after latest "/" in url , did this:
var current_url = $(location).attr('href'); var clean_url = current_url.substring(current_url.lastindexof('/') + 1);
but it's not working because text (or parameters) after latest "/" , don't want that. how? what's wrong in code?
substring
returns string starting @ index specified first parameter, , going until index specified second parameter, or end if there isn't second parameter. try this:
var current_url = location.href; var clean_url = current_url.substring(0, current_url.lastindexof('/') + 1);
Comments
Post a Comment