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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -