Document.prototype.greenify = function(){
return {
style : function(){
return this.color = "green";
}
}
};
document.getElementsByTagName("H1")[0].greenify();
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>TEST</h1>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
Hey out there,
I wanna build a 'dot function'. My function for trial should 'greenify' my element. I already tried to add the function to Window- object but I came to the same result. So, now my question... What I did wrong or did I forget something? I'm thankfully for each answer I receive :)
greenify(), which accepts a HTML element, and do that instead.