DEV Community

Discussion on: 7 Killer JavaScript One-Liners that you must know

Collapse
 
othmanekahtal profile image
Othmane kahtal

Nice hacks bro
My favourite tip : select elements directly by id without getElementById
<h1 id='h1'></h1>
you can do to select element :
h1.style.Color instead document.getElementById('h1').style.Color

Collapse
 
ibrahimwehbi profile image
Ibrahim Wehbi

that's why it is a bad practice to use id(attribute) in HTML elements and that you should always use class(attribute), in larger scale applications you will face unpredictable behavior because Javascript will be filled with global variables

Collapse
 
ikamran01 profile image
Kamran Ahmad

nice bro that's great