@dz8540/custom-checkbox
v1.0.1
Published
DZ's custom checkbox library
Downloads
6
Readme
DZ Custom-checkbox
In order to use, it is enough to find the element you need, and then pass it to the class.
Installation
- Via npm
npm i @dz8540/custom-checkbox
- Manually - all you need is in the "Dist" folder.
<link href="/Your-path/customCheckbox.min.css" rel="stylesheet">
<script src="/Your-path/CustomCheckbox.min.js"></script>
Example
HTML
<label class="Checkbox" id="firstCheckbox" data-name="First Checkbox">
<input type="checkbox" class="Checkbox__input" data-id="dz-input">
<div class="Checkbox__checkbox">
<span class="Checkbox__fill" data-id="dz-checkboxInput"></span>
</div>
<span class="Checkbox__text">Checkbox</span>
</label>
JS
let el = document.querySelector(el);
new Checkbox(el);
Instruction:
- Text value print in last span in the component.
- No id attribute required for input.
- Input maintains checked attribute.
- Input maintains disabled attribute.
- Component maintains data-name attribute, to you can set component name.
- There are methods.
Methods
- action - programmatically set checked or disabled attribute for input element.
new Checkbox(el).action('checked');
- on - event subscribe for input element into component
new Checkbox(el).on(eventName, your callBack);
End
That's all! Enjoy this (〜 ̄▽ ̄)〜