You can save time typing document.getElementById(elementId) and document.createElement(elementType) by following a simple trick:
- Create a function which executes either of the above lines of code
- Assign the function to a variable
- Use that variable instead of typing the redundant code
Here is a demo with screenshots:
Top comments (0)