
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
wc-dropdown
Advanced tools
Dropdown menu web component.
$ npm install wc-dropdown
<script src="dropdown.js"></script>
<form action="#" method="POST">
<dropdown-menu
placeholder="Please select one"
maxitems="5"
name="city"
options="[
{"name": "option 1", "value":"A01"},
{"name": "option 2", "value":"A02"},
{"name": "option 3", "value":"A03"},
{"name": "option 4", "value":"A04"}
]"
></dropdown-menu>
<input type="submit" value="submit" />
</form>
The demo page: https://yishiashia.github.io/dropdown.html
If you want to customize this web component, you can import the library and
implement your new class by extend Dropdown
.
import Dropdown from "wc-dropdown";
class customizedDropdown extends Dropdown {
// override here
}
String
type. The hint words of dropdown menu.
Number
type. The max length of displayed items at one time in the dropdown menu.
String
typs. The name of input, it would be the POST parameter name.
Array of option item. Each option item include at least name
and value
fields.
example:
[
{"name": "option 1", "value": "a1"},
{"name": "option 2", "value": "a2"},
{"name": "option 3", "value": "a3"}
]
When passing options
as element attribute, it must escape the quotes mark, for example:
[
{"name": "option 1", "value": "a1"},
{"name": "option 2", "value": "a2"},
{"name": "option 3", "value": "a3"}
]
Another way to set options is using javascript:
let menuElement = document.querySelector('dropdown-menu')
menuElement.options = [
{name: "option 1", value: "option_1"},
{name: "option 2", value: "option_2"},
{name: "option 3", value: "option_3"}
]
When user choose one option, a change
event will be dispatch, and you can bind an event listener to handle it:
let menuElement = document.querySelector('dropdown-menu')
menuElement.addEventListener('change', function(option) {
console.log(option.detail)
/*
output example:
{ name: "option 2", value: "option_2" }
*/
})
FAQs
Dropdown menu web component
The npm package wc-dropdown receives a total of 0 weekly downloads. As such, wc-dropdown popularity was classified as not popular.
We found that wc-dropdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.