This tab is highlighted when I click this link for the website navigation like above. when I click another page, it will jump to the corresponding page, the navigation labels corresponding to the current page will also be highlighted. what is the general design scheme? What are some good and elegant solutions? Please...
This tab is highlighted when I click this link for the website navigation like above. when I click another page, it will jump to the corresponding page, the navigation labels corresponding to the current page will also be highlighted. what is the general design scheme? What are some good and elegant solutions? Please answer.
My personal solutions are:
1. traverse the URLs of these tags during windows loading. if they are the same as the url of the current page, they will be highlighted;
2. use cookies to store the navigation index of the current click, read the index value after entering the current page, and highlight the tag marked by the index value;
I feel that these two methods are a bit unreliable, so I want a better idea.
Reply content:
This tab is highlighted when I click this link for the website navigation like above. when I click another page, it will jump to the corresponding page, the navigation labels corresponding to the current page will also be highlighted. what is the general design scheme? What are some good and elegant solutions? Please answer.
My personal solutions are:
1. traverse the URLs of these tags during windows loading. if they are the same as the url of the current page, they will be highlighted;
2. use cookies to store the navigation index of the current click, read the index value after entering the current page, and highlight the tag marked by the index value;
I feel that these two methods are a bit unreliable, so I want a better idea.
JavaScript
You can usehrefThe property is the same as the page URL.
You can also add a custom data attribute for each element, as shown in figuredata-patternThen put the regular match in it.
JSFiddle: https://jsfiddle.net/bd4g5f2h/
I don't think this is necessary. There are three or five webpages. You can create a highlighted class. Then you can set a highlighted navigation for each page. If you use a template engine. In this step, you can use the template engine. If you use a single-page application, consider using js, or judging # The Following.