Over a million developers have joined DZone.

No More NULL Returned By GetElementById

// 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; }

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

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

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

{{ parent.tldr }}

{{ parent.urlSource.name }}