Here is my url:
https://sub.domain.com/core/subsite/piano/page/...
I need to take the string 'piano', and then apply it to elements on the page. The string will not always be ‘piano’, i need to take the 3rd section of the URL.
(Below is what I currently have which uses the breadcrumb of the page to identify what page the users is currently viewing) however I’d like to take 'piano' as the class to apply:
$(function() {
$('span .breadcrumb').each(function(){
$('#Nav').addClass($(this).text());
$('#Content').addClass($(this).text());
$('.xpanding_footer').addClass($(this).text())
$('#footer').addClass($(this).text());
});
});
I can only guess that you are asking about third parameter in pathname when you are splitting using backslash.
So, you can get the value using: