Im trying to get the last string from a URL for example...
http://www.mywebsite/blog/this-post
I want to use jQuery to get 'this-post' Ive the following...
$('img.gigthumb').each(function(){
var foo = $(this).parent().attr('href').split('/');
$(this).attr('src','/lic/wp-content/uploads/2012/01/'+foo[1]+'.jpg');
})
only it doesn't work and I presume thats because I have multiple '/' within the URL, any idea how to target just the last?
Hope this makes sense!
.pop()vsarr[arr.length-1]jsperf.com/pop-vs-arr-length-1