I need help with my "switch" code I want to validate the final string of a url to change a background by assigning a class and applying the corresponding CSS, it always returns the "default" case and does not apply to other cases with any URL.
var url_location = window.location.href;
switch (url_location) {
case window.location.href.indexOf('?osf_portfolio_type=Bodega'):
jQuery('.page-title-bar').addClass('propiedad-bodega');
break;
case window.location.href.indexOf('?osf_portfolio_type=Terreno'):
jQuery('.page-title-bar').addClass('propiedad-terreno');
break;
case window.location.href.indexOf('?osf_portfolio_type=Oficina'):
jQuery('.page-title-bar').addClass('propiedad-oficina');
break;
case window.location.href.indexOf('?osf_portfolio_type=Local+comercial'):
jQuery('.page-title-bar').addClass('propiedad-local-comercial');
break;
default:
jQuery('.page-title-bar').addClass('propiedades-site');
break;
}
Thank you for your help!