I'm facing a challenge in creating a class with chained functions, and I could really use some assistance. Currently, this is what I have:
robin = new batman("myiv");
var batman = (function() {
var me = this;
function batman(id){
me._id=id;
document.getElementById(id).addEventListener('mousemove', me.mouseMoving.bind(me),true);
}
this.mouseMoving = function(){
document.getElementById(me._id).style.background="orange";
}
return batman;
}
This pseudo code outlines my desired outcome. Essentially, I want to input the ID of an element in my HTML and be able to chain functions like onclick etc., allowing the specified code inside those functions to execute – for example, changing background colors.
Is this achievable?
superman("mydiv"){
.onmouseover(){
document.getElementById(the_id).style.background="#ffffff";
},
.onmouseout(){
document.getElementById(the_id).style.background="#000000";
},
etc...
}
Edit: included missing code: "return batman;"