I have an application that has this format scattered around but I dont know what kind it is. It's not jQuery, so what is it?
$('some_edit').style.display  = "block";
$('some_views').style.display = "none";
I get this in firebug and I know the element is present:
$("some_edit").style is undefined
                It could be many things - examine the source code (or use Firebug) and see what JS libraries are being loaded.
A lot of people have defined the '$' symbol as a substitute for document.getElementById().
Basically:
function $(id) { return document.getElementById(id); }
$("ElementID").innerHTML = "Text"; //Usage
A more proper, "namespace" example:
var DOM = { // creating the namespace "DOM"
    $: (function() {
        if(document.getElementById)
            return function(id){ return document.getElementById(id); }
        else if(document.all)
            return function(id) { return document.all[id]; }
        else
            return function(id) { /* I don't even want to get into document.layers */ }
    })()
};
// Later in the code:
{
    function ExampleFunction() {
        // ...
        DOM.$("ElementID").style.backgroundColor = "#96d0a0"; // a nice minty green color
        // ...
    }
}
I have used a self-invocation pattern (function(){ ... }()) in this example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With