Search.../

onItemMouseIn( )

Adds an event handler that runs when a user hovers over a mobile menu item.

Syntax

function onItemMouseIn(handler: MenuItemMouseEventHandler): MenuItem
handler: function MenuItemMouseEventHandler(event: MenuItemMouseEvent): void

onItemMouseIn Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when the mobile menu item is hovered over.

Returns

The mobile menu item on which the event is now registered.

Return Type:

MenuItem
NAME
TYPE
DESCRIPTION
label
string

The label of the mobile menu item. This is text that the site visitor sees in the mobile 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 mobile menu defaults to the mobile 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 mobile 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 mobile menu item gets its value from the name of the page that the link property references.

Min: 1 character

Max: 40 characters

selected
boolean

Setting selected to true for a mobile menu item causes the item to appear highlighted and to expand any of its sub-items in the menu container. 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 sets selected to true 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 mobile menu (as defined when managing the mobile menu in the Editor) and not derived from a currently-active page in a custom mobile menu.

Default: false

link
string

Optional link for the mobile 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 as https://www.mortgagecalculator.org/.
  • wix:document://<location>: A document stored in the Media Manager, such as wix:document://v1/9bec_52fb06ea/filename.xls.
  • mailto:<email-address>?subject=<subject>: An email, such as mailto:michael@example.com?subject=Coming%20Soon.
  • tel:<phone number>: A phone number, such as tel:+1-555-555-5555.

If link isn't specified, the corresponding label isn't clickable.

Specifying an empty string is not supported. The mobile menu defaults to the mobile menu items as defined in the Editor and an error is logged to the console.

Min: 1 character

Max: 40 characters

target
string

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

menuItems
Array<MenuItem>

Menus can have 1 additional level of submenus.

MenuItemMouseEventHandler Parameters

NAME
TYPE
DESCRIPTION
event

The mouse event that occurred on a menu item.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Get information about the mobile menu item that the mouse hovered over

Copy Code
1$w('#myMenu').onItemMouseIn( (event) => {
2 let label = event.item.label; // "Mileage Program"
3 let link = event.item.link; // "https://myairlines.com/frequentflier"
4} );
Show/hide text if hovering over a mobile menu item

This example demonstrates how to show a message if the mouse hovers over a mobile menu item that links to an external site.

Copy Code
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});
6
7$w('#myMenu').onItemMouseOut(event => {
8 if (event.item.link === 'https://www.mortgagecalculator.org/') {
9 $w('#displayMessageText').hide();
10 }
11});
12