Last Updated on April 26, 2023 by Roshan Parihar
HTML menuitem tag is used to a specify a list of commands.
These menus of commands come under HTML menu tag and should be performed by the user.
Syntax
1 |
<menuitem label="put label here" onclick="put your script function function1()"></menuitem> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<img src="../images/nature.jpg" id="myPic" width="250" height="250" alt="How to show HTML menuitem in HTML" contextmenu="mymenuimg"/> <menu type="context" label="mycommands" id="mymenuimg"> <menuitem label="Black" onclick="changeColor('black');"></menuitem> <menuitem label="white" onclick="changeColor('white');"></menuitem> <menuitem label="yellow" onclick="changeColor('yellow');"></menuitem> <menuitem label="green" onclick="changeColor('green');"></menuitem> </menu> <script type="text/javascript"> function changeColor (thisColor) { document.getElementById('myPic').style.borderColor = thisColor; } </script> <p>These commands can be seen by right click on the image. Select your option and look up the changes.</p> <p>The example works only in Firefox.</p> |
Output
These commands can be seen by right click on the image. Select your option and look up the changes.
The example works only in Firefox.
List of HTML menuitem tag attributes
Sr. No. | Attribute options | Description |
---|---|---|
1 | type | Specify the type of menu to display. The values for this attribute are radio,command and checkbox |
2 | label | This specified the label of the menu. |
3 | default | This specified the menu item as a default menu. Its value is default |
4 | checked | This specified the menu item, whether it is selected or not. |
5 | disabled | This specified the menu item, whether it is disabled or not. |
6 | icon | This specified the menu item icon. The value for this is a URL |
7 | radiogroup | This specified the menu item name of the group of commands that will be toggled. This toggled when the command is toggle. This only work for the type radio group. |