HTML CSS examples for HTML Tag:menuitem
The <menuitem> element defines a menuitem.
Permitted Parent | <menu> |
---|---|
Content | None. It is an empty element. |
Start/End Tag | Start tag: required, End tag: forbidden |
Version | New in HTML5 |
The example below shows the <menuitem> tag.
<!DOCTYPE html> <html lang="en"> <head> <script type="text/javascript"> function zoomin(){<!-- w w w . ja va 2 s .c om--> var myImg = document.getElementById("sky"); var curr_width = myImg.clientWidth; myImg.style.width = (curr_width + 50) +"px"; } function zoomout(){ var myImg = document.getElementById("sky"); var curr_width = myImg.clientWidth; myImg.style.width = (curr_width - 50) +"px"; } </script> </head> <body> <img src="https://www.java2s.com/style/demo/Opera.png" id="sky" width="250" contextmenu="skymenu"> <menu type="context" id="skymenu"> <menuitem label="Zoom In" onclick="zoomin()"> <menuitem label="Zoom Out" onclick="zoomout()"> <menuitem label="Reload Image" onclick="window.location.reload();"> </menu> </body> </html>
The following table shows the attributes that are specific to the <menuitem> tag.
Attribute | Require | Value | Description |
---|---|---|---|
label | Required | text | name of the menu item, as shown to the user. |
checked | Optional | checked | Boolean attribute sets if menu item is selected when the page loads. |
command | Optional | ID | ID of a separate element, indicating a command to be invoked indirectly. |
default | Optional | default | Boolean attribute sets the menu item as default command. |
disabled | Optional | disabled | Boolean attribute sets if the menu item is disabled. |
icon | Optional | URL | an icon for the menu item. |
radiogroup | Optional | group-name | sets the name of a group of commands to be toggled as radio buttons when selected. Only be used where the type attribute is radio. |
type | Optional | checkbox command radio | sets the type of menu item. The default value of this attribute is command. |