diff --git a/index.js b/index.js index 6225aae..75dd477 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ class IdmQuantityPicker{ - constructor({selector , min = 1, max = 99}) { - const container = document.querySelector(selector); + constructor({selector , min, max, ref}) { + const container = selector ? document.querySelector(selector) : ref; if(!container){ console.error("IdmQuantityPicker: container not found."); return; @@ -13,6 +13,18 @@ class IdmQuantityPicker{ } this.input = input; + if(typeof min === "undefined"){ + min = this.input.min; + }else{ + this.input.min=min; + } + + if(typeof min === "undefined"){ + max = this.input.max; + }else{ + this.input.max=max; + } + this.min = min; this.max = max; this._value = Number.parseInt(input.value);