way2web-click-limit
v0.0.3
Published
Disable the element on a click limit.
Downloads
111
Readme
Click Limit package
With this package you can set a limit on how many times you can click on the element.
Installation
npm install way2web-click-limit
Basic Usage
var element = $('.js-limited-click:first');
var test = new ClickLimit(element).init();
You can set a data attribute click-max to the element, to set the click limit.
The default value is 1
, so you can click the element only one time.
.click()
This function will called when you click on the element.
A variable clicked
will be increased by 1
.
The property disabled
will be set on the element.
.unlock()
You can call this function to reset the clicks on the element, so you can click again on the element.
The variable clicked
will be set to 0
.
The property disabled
will be removed from the element.
.getClicked()
This function returns how many times you have clicked on the element.
.getMax()
This function returns how many times you can click on the element.
Test the package.
npm run lint
This will only lint your scripts.
npm test
This will run all the tests in the test folder with mocha.