-2
I have several variables like this, that call an HTML element always with the same name:
var $inputFromA = $(".inputFromA");
It’s at least 10: inputFromA
, inputFromB
, inputFromC
…
All these variables also call exactly the same function:
$inputFromA.on("input", function () {
var val = $(this).prop("value");
if (val < min) {
val = min;
} else if (val > to) {
val = to;
}
instance.update({
from: val
});
});
It is possible to create a constructor function or constant class so that I can only declare the variable name and call only the class/function?
I imagine it would be something like:
class InputFrom () {}
var inputFromA = new InputFrom;
My difficulty is due to the amount of parameters that such a function should have. Someone could give me a strength with this?
What is this
instance
in the code? Why do you want to create the class? Your question is not clear; it would be good for you to [Edit] to make it a little clearer.– Luiz Felipe
I am working with Ion.Rangeslider (http://ionden.com/a/plugins/ion.rangeSlider/index.html) and
instance
is required for the slider to fill ainput
with a number.– Arnon