用PHP實現簡單的滑動菜單

來源:互聯網
上載者:User

<style>
table {font-size = 9pt}
td {height = 20px}
</style>
<body>
<span id="menus"></span>
<span id="view"></span>
</body>
<script for=pad event=onclick>
// 大類節點點擊響應
for(var i=1;i<this.parentElement.rows.length;i =2)
 this.parentElement.rows[i].style.display = "none";
this.parentElement.rows[this.rowIndex 1].style.display='block';
view.innerHTML = this.v1 ":" this.v2; // 根據大小類自行構造相應動作
</script>
<script for=bar event=onclick>
// 小類節點點擊響應
view.innerHTML = this.v1 ":" this.v2; // 根據大小類自行構造相應動作
</script>
<script>
/**
* 產生菜單的html代碼串
* 入口參數為菜單預設開啟的大類號
*/
function menu(n) {
  this.ar = new Array(
  /**
   * 參數數組
   * 列1:大類
   * 列2:小類
   * 列3:標題
   */
  new Array(1,0,"大類一"),
  new Array(1,1,"小類一"),
  new Array(1,2,"小類二"),
  new Array(2,0,"大類二"),
  new Array(2,1,"小類一"),
  new Array(2,2,"小類二"),
  new Array(2,3,"小類三"),
  new Array(3,0,"大類三"),
  new Array(3,1,"小類一"),
  new Array(3,2,"小類二"),
  new Array(4,0,"大類四"),
  new Array(4,1,"小類一"),
  new Array(4,2,"小類二"),
  new Array(4,3,"小類三")
  );
  this.width =120;
  this.bgcolor = "#f0f0f0";
  this.bordercolorlight = "#c0c0c0";
  this.bordercolordark = "#FFFFFF";
  this.tr_bgcolor = "#d0d0d0";
  var s = "<table border=1 align=center width=" this.width " bgcolor=" this.bgcolor " bordercolorlight=" this.bordercolorlight " bordercolordark=" this.bordercolordark " CELLPADDING=0 CELLSPACING=0>"
  for(var i=0;i<this.ar.length;i ) { // 構造菜單的html結構,其中將大小類編號作為自訂參數,以便事件響應時使用。
    if(this.ar[i][1] == 0) {
      if(i > 0)
        s = "</table></td></tr>";
      var vk = this.ar[i][0]==n?"block":"none";
      s = "<tr id='pad' bgcolor=" this.tr_bgcolor " v1=" this.ar[i][0] " v2=" this.ar[i][1] "><td align=center>" this.ar[i][2] "</td></tr><tr style='display:" vk "'><td><table width=100%>";
    }else
      s = "<tr><td id='bar' v1=" this.ar[i][0] " v2=" this.ar[i][1] ">" this.ar[i][2] "</td></tr>";
  }
  s = "</table></td></tr></table>";
  return s;
}
/*** 建立菜單 ***/
menus.innerHTML = menu(4);
</script>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.