1.1.0 • Published 2 years ago

@karim04/dropdown-menu v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@karim04/dropdown-menu

a Javascript module that creates ready-to-go dropdown menus Preview Image

installation

npm install --save @karim04/dropdown-menu

Usage

import the module in your code
import Dropdown from '@karim04/dropdown-menu';
and create a dropdown menu using:
const menuName = Dropdown.create(triggeringElement);

pass any element to the create method and it will create a dropdown menu for that element that will be toggled by clicking on that triggering element, and it returns you the dropdown menu object

disabling default styling

if you want to disable default styling to add your own, pass false to the second paramater in the create method

const menuName = Dropdown.create(triggeringElement, false);

Returned Object Methods and properties

Add Menu Item
menuName.add(itemElement, onClickFunc);

first arguement takes an element or a string and adds it to the menu as an item, and the second argument takes a function that is trigged when the item is clicked

menu property
menuName.menu;

returns the menu element that contains the items

element property
menuName.element;

returns the parent element that triggers the menu

License

This project is licensed under the MIT license.

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago