Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

No More NULL Returned By GetElementById

DZone's Guide to

No More NULL Returned By GetElementById

·
Free Resource
// If you search for an ID that doesn't exist, getElementById(id) will return NULL, filling your error console with some stuff in it.

Now, everything is clear. No more error, no more NULL return. getElementById will now being silent for ever.


function GetID(id) { return (document.getElementById(id))?document.getElementById(id):false; }
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}