Code completion on your own function like document.getElementById

Hi folks,

I'm not using JQuery for a project I'm doing (I have my reasons), and instead only a very simple lightweight framework. 

One of the first things you do in this case, however, is to shorten document.getElementById because it's used so much, e.g. :

function $$(elementId){ return document.getElementById(elementId); }

…such that your code ends up looking like this:

$$("someElementBla").style.display = “none”;

PhpStorm (et. al.) will nicely code-complete HTML element IDs in the “real” document.getElementById when you use the function. 

In like fashion, the JQuery $ function also does this code-completion.

So my question is, how do I make my function do this?

It seems like my issue would have to be a pretty common one since, if you aren't using JQuery or some other framework, you'd have the same problem. 

Thanks for any help you might have…





1 comment

Please sign in to leave a comment.