-
Notifications
You must be signed in to change notification settings - Fork 24
05. Get Element by ID (dgI.js)
Pimp Trizkit edited this page Mar 7, 2018
·
2 revisions
| << Previous | Back to Table of Contents | Next >> |
"21 or over." - PT
This is just an alias function to shorten other JS code. I just reinvented the exact same wheel here.
"dgI" alias for "document.getElementByID".
Searches inside document for a HTML Element with id equal to the provided string, and returns it. NOTE: The id attribute is meant to be unique amongst all elements in the DOM that use it.
const dgI=(i)=>document.getElementById(i)||false;let e = dgI("myID");A HTML Element, from inside document, that has id equal to the parameter specified. NOTE: If no such element exists, false will be returned.
dgI(i)
i = < ID String > * REQUIRED
- A string to search in
documentfor the first occurance of an element with the sameid. - This function uses
document.getElementByID(), and is just an alias, except that it converts thenullto afalsewhen no element is found.
"Programming comfortably with my PJs." - PT