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
Post a Comment