
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
select-unique
Advanced tools
Given a group of HTML select elements with the same options, Select Unique will remove an option from the other select elements when it's selected, and put it back when it's changed.
Given a group of HTML select elements with the same options, Select Unique will remove an option from the other select elements when it's selected, and put it back when it's changed.
Checkout the demo here.
npm install select-unique
Or:
yarn install select-unique
Then:
import SelectUnique from 'select-unique';
const selects = new SelectUnique('.some-group select');
You can also give it some HTMLSelectElement
s:
const elements = [
document.querySelector('select:nth-of-type(2)'),
document.querySelector('select:nth-of-type(4)')
]
const selects = new SelectUnique(elements);
Or even a NodeList
:
const selects = new SelectUnique(document.querySelectorAll('select.question'));
If you want to ignore certain options:
const selects new SelectUnique(selector, {
ignoreOption: option => option.value === 'ignore_me_buddy'
});
You can also retrieve what's currently selected or remaining within the group:
selects.remaining().forEach(option => {
console.log(`text: ${option.text} value: ${option.value}`);
});
selects.selected().forEach(option => {
console.log(`text: ${option.text} value: ${option.value}`);
});
Include it in your html page (from jsdelivr or cdnjs):
<div id="my-select-group">
<!-- A bunch of selects -->
</div>
<script src="https://cdn.jsdelivr.net/npm/select-unique@VERSION/dist/select-unique.min.js"></script>
<script>
new SelectUnique('#my-select-group select');
</script>
Replace VERSION
in the src
URL with the desired version.
Skye Shaw (skye.shaw -AT- gmail)
Released under the MIT License: http://www.opensource.org/licenses/MIT
FAQs
Given a group of HTML select elements with the same options, Select Unique will remove an option from the other select elements when it's selected, and put it back when it's changed.
The npm package select-unique receives a total of 1 weekly downloads. As such, select-unique popularity was classified as not popular.
We found that select-unique 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
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.