What I want to approach is to create a custom Function that looks like this:
access('h1').content('Hello World');
And this is how I tried to accomplish that:
function access(Tag)
{
var Element = document.getElementsByTagName(Tag)[0];
this.content = function(Content)
{
if (Content !== undefined)
return Element.innerHTML = Content;
else return Element.innerHTML;
}
return Element;
}
So this Function shall be in the verge of changing the Content or just returning it. Unfortunately it does not work this Way.
So far I played with it for about an Hour to rewrite it and find a Solution on my own, but I have not been successfull and I also do not know how to describe this Problem to Google it.
How can I solve this it?