Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

.pop get second element of url

var parts = 'http://mywebsite/folder/file'.split('/');
var lastSegment = parts.pop(1) || parts.pop();  // handle potential trailing slash

console.log(lastSegment);
 Run code snippetHide results
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #element #url
ADD COMMENT
Topic
Name
9+3 =