I am trying to make a function that calls other functions depending on the class of an element that I am interacting with.
I would like to be able to use the class of an element to call a function, instead of using an if statement. Example below:
function validate(thisInput){
var thisClass = thisInput.attr("class").split(' ')[0];
validate + class(thisInput);
/*This is what I would like to happen:
the class is grabbed from above, then that class name (whatever it is)
calls it's own function. I will be creating a function for each class.
*/
}
function validateClassname(thisInput) {
//do something
}
As you can see, I am trying to find the class name, make it into it's own function (without using if statements to drive it) then have that function do whatever it needs to do.
Am I looking at this wrong? Should I be going about it a different way? Thank you