onItemMouseOut( )
Adds an event handler that runs when a user stops hovering over a menu item.
Syntax
function onItemMouseOut(handler: MenuItemMouseEventHandler): MenuItemhandler: function MenuItemMouseEventHandler(event: MenuItemMouseEvent): void
onItemMouseOut Parameters
NAME
TYPE
DESCRIPTION
The name of the function or the function expression to run when the menu item is not hovered over.
Returns
The menu item on which the event is now registered.
Return Type:
NAME
TYPE
DESCRIPTION
The label of the menu item. This is text that the site visitor sees in the menu and can click to navigate.
If not specified, and the page that the link property references is:
- An external page or an empty string: The menu defaults to the menu items based on site pages only, as defined in the Editor, and an error is logged to the console.
- A page nested under a folder: The specific menu item label defaults to the name of the corresponding page as defined in the Editor.
- A regular, non-nested, site page: The
label
for the menu item gets its value from the name of the page that thelink
property references.
Min: 1 character
Max: 40 characters
Setting selected
to true
for a menu item causes the item to appear highlighted in the menu element.
You can use this property to indicate which page is currently being displayed.
Note: The value of
selected
isn't validated against which page is actually displayed. For example, you can write code that misleadingly setsselected
totrue
for multiple menu items.
When not defined explicitly using the selected
property, the selected
value is derived from the currently-active page in the site's main menu
(as defined when managing the menu in the Editor) and not derived from a currently-active page in a custom menu.
Default: false
Optional link for the menu item. This is the link the site visitor navigates to when they click on a menu item. The different types of links you can use are:
/localPageURL
: Another page on your site, such as/about
or/rentals/shortterm
./
: Your site's home page.http(s)://<url>
: An external web address, such ashttps://www.mortgagecalculator.org/
.wix:document://<location>
: A document stored in the Media Manager, such aswix:document://v1/9bec_52fb06ea/filename.xls
.mailto:<email-address>?subject=<subject>
: An email, such asmailto:michael@example.com?subject=Coming%20Soon
.tel:<phone number>
: A phone number, such astel:+1-555-555-5555
.
If link
isn't specified, the corresponding label isn't clickable.
Specifying an empty string is not supported. The menu defaults to the menu items as defined in the Editor and an error is logged to the console.
Min: 1 character
Max: 40 characters
Whether the link opens in the same window/tab or in a new window/tab.
_self
. The page opens in the same window/tab._blank
. The page opens in a new window/tab.
Note:
target
doesn't work when previewing your site.
Default: _self
Menus can have additional levels of submenus. Vertical menus can have 1 level of submenus. Horizontal menus can have 2 additional levels of submenus.
A unique ID that can be used to customize events triggered on a menu item. For example, when a visitor clicks a menu item, the ID can be checked in order to trigger the appropriate action for that menu item.
MenuItemMouseEventHandler Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
Was this helpful?
1$w('#myMenu').onItemMouseOut( (event) => {2 let label = event.item.label; // "Mileage Program"3 let link = event.item.link; // "https://myairlines.com/frequentflier"4} );
This example demonstrates how to hide a message if the mouse stops hovering over a menu item that links to an external site.
1$w('#myMenu').onItemMouseIn(event => {2 if (event.item.link === 'https://www.mortgagecalculator.org/') {3 $w('#displayMessageText').show(); // "You are about to leave the Wix site"4 }5});67$w('#myMenu').onItemMouseOut(event => {8 if (event.item.link === 'https://www.mortgagecalculator.org/') {9 $w('#displayMessageText').hide();10 }11});12