Jonathan Wood
Jonathan Wood

Reputation: 67193

Meaning of $get('0')?

I just upgraded to jQuery 1.12 from an older version. I'm going through the code, trying to resolve breaking changes.

One such change is occurring in the following code:

$(document).ready(function() {
    Sys.Application.add_unload(applciationUnloadHandler);
    function applciationUnloadHandler() {
        var contactDropDown = $get('0');
        createCookie('NewProgram_ContactID_Cookie', contactDropDown.value, null);
    }
});

This code fails because $get('0') returns null.

But I really don't understand what this is supposed to be doing. I don't see $get() defined anywhere. I can see from looking at the code behind that the '0' argument represents a contact ID, but I can't see what the code is supposed to be doing.

Upvotes: 0

Views: 200

Answers (2)

eblin
eblin

Reputation: 446

$get is a shortcut function for Sys.UI.DomElement.getElementById

The $get method provides a shortcut to the getElementById method of the Sys.UI.DomElement class.

Reference

Upvotes: 2

Malk
Malk

Reputation: 11983

$get is defined in the ASP.NET AJAX Client Side Library that should be included if you are using a ScriptManager.

Upvotes: 1

Related Questions