This has been driving me crazy because I can't find anything on Google. Maybe it's because I don't know the right terminology to search right. But this is what I'm trying to do.
I want to create a function that acts like an object. I'm think it's called a method, though I could be wrong.
Check this out, this is some pseudocode of what I would like it to do.
function myMethod(){
var p = this.getAttribute('x');
var p = p+1;
return p;
}
function otherFunction(){
var q = document.getElementByID('Element').myMethod();
alert(q);
}
So, I can't get this to work. It keeps saying myMethod() is undefined and not a function.