简体   繁体   English

如何在下面的编码中将鼠标悬停事件更改为鼠标单击事件

[英]How to Change Mouse over event to Mouse Click Event in below coding

This is JavaScript code for menu's.这是菜单的 JavaScript 代码。 This script is in the form of Mouse Over Event, but I need to change it to Mouse Click Event.这个脚本是鼠标悬停事件的形式,但是我需要把它改成鼠标点击事件。 Please help me to change this one.请帮我改变这个。

    var dolphintabs={subcontainers:[], last_accessed_tab:null,

    revealsubmenu:function(curtabref){
    this.hideallsubs()
    if (this.last_accessed_tab!=null)
        this.last_accessed_tab.className=""
    if (curtabref.getAttribute("rel")) //If there's a sub menu defined for this tab     item, show it
    document.getElementById(curtabref.getAttribute("rel")).style.display="block"
    curtabref.className="current"
    this.last_accessed_tab=curtabref
    },

      hideallsubs:function(){
          for (var i=0; i<this.subcontainers.length; i++)
            document.getElementById(this.subcontainers[i]).style.display="none"
},


     init:function(menuId, selectedIndex){
    var tabItems=document.getElementById(menuId).getElementsByTagName("a")
        for (var i=0; i<tabItems.length; i++){
            if (tabItems[i].getAttribute("rel"))
                       this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("rel") //store id of submenu div of tab menu item
        if (i==selectedIndex){ //if this tab item should be selected by default
            tabItems[i].className="current"
            this.revealsubmenu(tabItems[i])
        }
    tabItems[i].onmouseover=function(){
    dolphintabs.revealsubmenu(this)
    }
    } //END FOR LOOP
}

 }

For Sample Please See the below Link.样品请见以下链接。 Click Here to View the Sample of it http://www.javascriptkit.com/script/script2/tabset/index.shtml 单击此处查看它的示例http://www.javascriptkit.com/script/script2/tabset/index.shtml

Change this改变这个

tabItems[i].onmouseover=function(){
    dolphintabs.revealsubmenu(this)
}

to

tabItems[i].onclick=function(){
    dolphintabs.revealsubmenu(this)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM