---
title: "opencart 在主菜单上设置current_item 在菜单上高亮当前分类"
author: "ynial"
date: "2013-03-18T23:29:45Z"
tags: []
categories: ["互联网"]
slug: "opencart-current-item"
draft: false
lastmod: "2013-03-18T23:29:45Z"
id: 1831515
url: "https://ynial.iteye.com/blog/1831515"
---

```javascript

$(function(){
	function getURLParameter(name) {
		return decodeURI(
			(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,""])[1]
		);
	}

	var path = getURLParameter("path");
	if (path != "") {
		$("#menu li a").each(function() {
			if ($(this).attr('href').indexOf('path=' + path) > -1) {
				$(this).css("background-color", "#000");
			}
		});
	}
})

```