The left-side category navigation menu is the most direct category of E-commerce shopping navigation.
Main points of attention in js:
1. events include mouseover and mouseleave.
The onmouseover event occurs when the mouse pointer moves to the specified object.
The onmouseleave event occurs when the mouse pointer is removed from the specified object.
2. setTimeout and clearTimeout
The setTimeout method is used to call a function or computing expression after a specified number of milliseconds. SetTimeout () is executed only once.
The clearTimeout method can cancel the timeout set by the setTimeout () method.
Code snippet:
The action taken when the mouse moves to the li element and removes the element.
_this.showlist.find(".item").live("mouseover", $ = $(), show = _this.showlist.find(".show"), len =(!!(!!= setTimeout(".show,.tri"".tit").removeClass("on" index = $.index(),tmpheight = $.find(".show").height(),topval = 0(index < 5= index * (-41"top": topval + "px" (index > ( len - 5= -tmpheight + (len - 1 -index) * 41 + 20"top": topval + "px" tmpheight = $.find(".show"= -tmpheight/2 + 10; show.css({"top": topval + "px".find(".show,.tri".find(".tit").addClass("on"".item").live("mouseleave", $ = $(= setTimeout(.find(".show,.tri".find(".tit").removeClass("on"
Pay attention to css
1. position: Use of relative and position
2. Clear floating
3. Use of hover pseudo classes
Code Demonstration:
If the settings are displayed, "navSwitch": "navopen" is hidden by default.
The default effect is as follows: