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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -