这个是库文件
<ul>
<!--{foreach from=$categories item=cat}-->
<li id="caroot{$cat.id}" ><A href="{$cat.url}" onMouseOver="show_ca('{$cat.id}','{$cat.url}');" onClick=""><strong>{$cat.name|escape:html}</strong></A> </li>
<div id="ca{$cat.id}" >
<!--{foreach from=$cat.children item=child}-->
<span style="text-indent:15px;" ><A href="{$child.url}">{$child.name|escape:html}</A></span>
<!--{/foreach}-->
</div>
<!--{/foreach}-->
</ul>
在显示分类的页面加这个JS进去
function hidden_ca(){
for(i=1;i<400;i++){
if(document.getElementById("caroot"+i)){
if(document.getElementById("ca"+i)){
document.getElementById("ca"+i).style.display="none";
}
}
}
//document.getElementById(name+myid).style.display="";
}
function show_ca(thisid,thisurl){
for(i=1;i<400;i++){
if(document.getElementById("caroot"+i)){
document.getElementById("ca"+i).style.display="none";
}
}
if(document.getElementById("ca"+thisid).innerHTML!=""){
document.getElementById("ca"+thisid).style.display="";
}else{
window.location.href="http://www.voogooddeal.com/"+thisurl+"&wzz";
}
}
hidden_ca();
演示网站: