Fix: menu link active state
This commit is contained in:
		
							parent
							
								
									d5cc0814bf
								
							
						
					
					
						commit
						02be3567ac
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		
							
								
								
									
										10
									
								
								js/main.js
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								js/main.js
									
										
									
									
									
								
							|  | @ -53,8 +53,18 @@ function setPage(path){ | ||||||
| 		window.scrollTo(0, 0); | 		window.scrollTo(0, 0); | ||||||
| 		$("#article-container").empty(); | 		$("#article-container").empty(); | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 		$("#left > a").each((i, elmt) => { | ||||||
|  | 			let hrefPath = elmt.attributes["href"].value; | ||||||
|  | 			if(hrefPath === "/" || path === "" || path === "/index.html") | ||||||
|  | 				hrefPath = "/home"; | ||||||
|  | 
 | ||||||
|  | 			$(elmt).toggleClass("active", hrefPath === path); | ||||||
|  | 		}); | ||||||
|  | 
 | ||||||
| 		$.ajax("/pages"+path+".md") | 		$.ajax("/pages"+path+".md") | ||||||
| 			.done((res) => { | 			.done((res) => { | ||||||
|  | 
 | ||||||
| 				$("#article-container").html(res); | 				$("#article-container").html(res); | ||||||
| 
 | 
 | ||||||
| 				const len = $("#article-container > article").length; | 				const len = $("#article-container > article").length; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue