javascript

This weird piece of code I always see in Javascript


I'm not Javascript expert, but the old Javascript I know is just a bunch of simple functions and variables like this:

function doSomething(){
    var data = "test";
    return data;
}

But lately I'm seeing some Javascript code like this:

$(document).ready(function(){
    $("#about").hide();
    $(".tababout").collapser({
        target: '#about',
        effect: 'slide',
        changeText: false,
    });
});

What the hell is this? What is it called? Is it easier and supported by all browsers? I need more informations about this please.


Solution

  • What you're looking at is jQuery. It's an external library but it supports most (if not all) browsers. You need to download it and include it with your project if you were to use it though, see Downloading jQuery for that.