Posted in Javascript onDecember 30, 2016
废话不多说了,直接给大家贴代码了,具体代码如下所示:
function leftmove(){ var oLeft_ul=document.getElementById('left_ul'); var aLeft_li=oLeft_ul.children;//获得左侧ul下的第一个子集li var aleft_ul_hidden=oLeft_ul.getElementsByTagName('ul'); var aleft_span_hidden=oLeft_ul.getElementsByTagName('span'); var arr=[]; var span_arr=[]; getclassname(aleft_ul_hidden,'cl_hidden',arr) getclassname(aleft_span_hidden,'sj',span_arr); for(var i=0;i<aLeft_li.length;i++){ aLeft_li[i].index=i; aLeft_li[i].onmouseenter=function(){ for(var j=0;j<aLeft_li.length;j++){ move(aLeft_li[j],{height:40}); span_arr[j].style.borderColor='#f2f2f2 #f2f2f2 #f2f2f2 #666'; span_arr[j].style.top='13px'; span_arr[j].style.left='8px'; } var ul_height=arr[this.index].children.length*40 move(aLeft_li[this.index],{height:40+ul_height}); span_arr[this.index].style.borderColor='#666 #0ad #0ad #0ad'; span_arr[this.index].style.top='17px'; span_arr[this.index].style.left='6px'; }; aLeft_li[i].onmouseleave=function(){ for(var j=0;j<aLeft_li.length;j++){ move(aLeft_li[j],{height:40}); span_arr[j].style.borderColor='#f2f2f2 #f2f2f2 #f2f2f2 #666'; span_arr[j].style.top='13px'; span_arr[j].style.left='8px'; } }; arr[i].onmouseover=function(){ for(var i=0;i<arr.length;i++){ span_arr[i].style.borderColor='#f2f2f2 #f2f2f2 #f2f2f2 #666'; span_arr[i].style.top='13px'; span_arr[i].style.left='8px'; } span_arr[this.parentNode.index].style.borderColor='#666 #f2f2f2 #f2f2f2 #f2f2f2'; span_arr[this.parentNode.index].style.top='17px'; span_arr[this.parentNode.index].style.left='6px'; }; arr[i].onmouseout=function(){ for(var i=0;i<arr.length;i++){ span_arr[i].style.borderColor='#f2f2f2 #f2f2f2 #f2f2f2 #666'; span_arr[i].style.top='13px'; span_arr[i].style.left='8px'; } span_arr[this.parentNode.index].style.borderColor='#666 #0ad #0ad #0ad'; span_arr[this.parentNode.index].style.top='17px'; span_arr[this.parentNode.index].style.left='6px'; }; } } leftmove();
JS实现类似百叶窗下拉菜单效果
- Author -
Ag_wenbi声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@