javascript - JS renaming methods -


i fed writing , reading getelementbyid , getelementsbytagname... makes programming harder me.

so want rename them. want them getid, gettags , getclasses.

it micro library after. how can result minimum cpu usage?

at least var doc = document; easy.

just assign them.

var doc = document;  doc.getid = doc.getelementbyid;  doc.gettags = doc.getelementsbytagname;  doc.getclasses = doc.getelementsbyclassname;  alert(doc.getid('foo').classname);
<div id="foo" class="classy"></div>

if want able leave out doc., you'll need define functions, e.g:

function getid(id) {     return document.getelementbyid(id); } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -