Ok, so i have this code, adding a method (from what i understand) to the HTML element prototype:
HTMLElement.prototype.fadeIn = function( seconds ) {
var self = this;
var miliseconds = seconds * 1000;
var hold = this.style.transition;
this.style.transition = "opacity " + seconds + "s ease";
this.style.opacity = 1;
setTimeout(
function () {
self.style.transition = hold;
return self;
},
miliseconds);
};
my intention is that, at the end of the timeout, the function will return the instance of the HTMLElement so i can chain the fadeIn function with another one.
However it does not, and doing a console.log to what it returns, it says it's undefined. Can anyone give some advice as to how can i do this?
Aucun commentaire:
Enregistrer un commentaire