js脚本实现树形菜单
用脚本语言实现树形菜单
在网页中,用js脚本实现的树形菜单:
可以新建html直接运行.方便自己查看
body,td,th {font-size: 14px;}
.leftmenu1 {font-weight: bold; cursor: hand; padding-top: 4px; height: 29px; text-align: left;}
.leftmenu2 {PADDING-LEFT:15px; height: 21px;text-align: left;}
div{ margin-top:90px; width:100%; text-align:center; }
function Show(id,i_id){
var on_img="https://www.360docs.net/doc/f22004272.html,/member/pic/ass04.gif";//打开时图片
var off_img="https://www.360docs.net/doc/f22004272.html,/member/pic/ass03.gif";//隐藏时图片
var obj=document.getElementById('c_'+id);
if(obj.style.display=="none"){
obj.style.display="";
i_id.src=on_img;
//将子菜单Id放入Cookies
var curShow = readCookie('curShow');
if(curShow!='')
{
var arr_curShow = curShow.split(',');
var found = false;
for(i=0;i { if(arr_curShow[i].toString()==id) {found=true;} } if(!found){writeCookie('curShow',curShow+','+id,12)} } else { writeCookie('curShow',id,12) } //将子菜单Id放入Cookies End }else{ obj.style.display="none"; i_id.src=off_img; //将子菜单Id从Cookies中移除 var curShow = readCookie('curShow'); if(curShow!='') { var arr_curShow = curShow.split(','); for(i=0;i { if(arr_curShow[i].toString()==id) {arr_curShow=arr_curShow.del(i--);} } curShow = arr_curShow.join(','); //alert(curShow); writeCookie('curShow',curShow,12) } //将子菜单Id从Cookies中移除End } } function readCookie(name) { var cookieValue = ""; var search = name + "="; if(document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; cookieValue = unescape(document.cookie.substring(offset, end)) } } return cookieValue; } function writeCookie(name, value, hours) { var expire = ""; if(hours != null) { expire = new Date((new Date()).getTime() + hours * 3600000); expire = "; expires=" + expire.toGMTString(); } document.cookie = name + "=" + escape(value) + expire; } Array.prototype.del=function(n) { //n表示第几项,从0开始算起。//prototype为对象原型,注意这里为对象增加自定义方法的方法。if(n<0) //如果n<0,则不进行任何操作。 return this; else return this.slice(0,n).concat(this.slice(n+1,this.length)); } window.onload = function a() { var curShow = readCookie('curShow'); var totalShow = 5; //自己修改一共有多少个二级分类 if(curShow!=''&&curShow!=null) { for(i=1;i<=totalShow;i++) { document.getElementById('c_'+i).display="none"; } var arr_curShow; arr_curShow = curShow.split(','); for(i=0;i<=arr_curShow.length-1;i++) { if(arr_curShow[i]!=''){document.getElementById('c_'+arr_curShow[i]).style.display="";} } } } 个人资料 基本信息 修改密码 我的简历 求职简历 求职意向 上传照片 简历预览 职位搜索 快速搜索 应聘管理 应聘记录 企业邀请 收藏职位 我的知识 我要提问 我要回答 发问记录 回答记录 分数记录
ASP NET+TreeView树型菜单操作实例(代码调试通过)
https://www.360docs.net/doc/f22004272.html, TreeView树型菜单操作实例(代码调试通过) 本实例完成TreeView树型菜单添加,修改,删除,绑定DropDownList功能,移动功能读者可以自行书写.aspx代码