if I have a constructor function and want to plug in a DOM element how do I do this? I figure I need to convert it to a string but I’m not sure & I can’t quite figure out how to convert it. Thank you.
function MyFunk(domElementVar,domElementString) {
this.domeElementVar = document.getElementById(this.domeElementString);
};
Your current function is a constructor that accepts two arguments: an element and a string. This means you would call it as
new MyFunk(document.getElementById(...), "...").What you want instead is a constructor that only accepts a string, and finds the element itself. Note that:
this.. They are variables available inside the function.this..So: