Advanced Search

View RSS Feed

JavaScript & Ajax

  1. document.getElementById shortcut

    I'm amazed at how many people don't use a very simple shortcut for document.getElementById. This is for all the people who don't use a javascript library like jQuery.

    All you have to do is include this code somewhere on your page

    Code:
    function $(element) {
    return document.getElementById(element);
    }
    Then when you want to use document.getElementById('id'); just type $('id'); instead.

    Example

    Code:
    <html>
    ...
    Categories
    JavaScript & Ajax