Quick function to quickly select elements by id

Posted 2 years ago

The below div is just a quick function I use to allow me to quickly select elements based on their id, rather than typing out “document.getElementById(‘idName’);” every time I need to select something, I can call the function to do the graft for me. “_(‘idName’)

    <div id='content'>

    function _ (e){
      return document.getElementById(e);
    console.log(_('content')); // Fired on it's own would log 
_('content').innerHTML = 'New Content'; // Would change the content div </script>