Trace under the page

Asked

Viewed 24 times

1

I’m trying to put a dash under the current page as in the image.

Como deve ficar

I need to do this with jQuery, it’s not an option to put one border-bottom on every open page. I thought I’d pick up the url page and if it is equal to some class (which I will assign to the button) it adds the style of border-bottom so. I’m a little lost and don’t know how to start or the best method, I just thought of the url but I don’t know how to run yet.

  • Do you already have any code made? So it’s easier to help you.

  • No, because as I said I have no idea where to start and I don’t even know if the method I said is the simplest.

  • Start by searching how to get the URL with Javascript; then study the syntax of if and see how to make comparisons; research how to change a CSS class via jQuery and finally write the CSS class that defines the edge. If you don’t get any part, you can go back and [Edit] the question in more detail. Good luck.

1 answer

2


One option is to take the url with Location and split (split) it by "/" and take the last part and compare with the fields:

var url = window.location.href;
var urlSplit = url.split("/");
var pagina = urlSplit[urlSplit.length-1];
console.log(pagina);

//aqui você compara a página com seu menu e marca o ativo

Browser other questions tagged

You are not signed in. Login or sign up in order to post.