a标签点击后,给a标签添加样式

	window.onload=function(){
		var a = document.getElementById("cate").getElementsByTagName("a");
		for(i=0,len=a.length;i<len;i++){
			 if (a[i].href == window.location.href ) {
			 	a[i].style.backgroundColor='#C1FFC1';
			 	a[i].style.fontWeight='bold';
			 }
		 }
	}

  

posted @ 2019-01-23 12:19  zhoudingzhao  阅读(1919)  评论(0编辑  收藏  举报