jQuery reference: basic jquery

Basic jquery template:

$(document).ready(function() {
    $('thingToTouch').event(function() {
        $('thingToAffect').effect();
    });
});

Beispiel #1:

$(document).ready(function() {
    $('div').click(function() {
        $('div').fadeOut('fast');
    });
    $('div').hover(function() {
        $('div').addClass('red');
    }); 
});

Beispiel #2:

$(document).ready(function() {
    $('div').mouseenter(function() {
        $('div').fadeTo('fast', 1);
    });
    $('div').mouseleave(function() {
        $('div').fadeTo('fast', 0.25);
    }); 
});

Leave a Reply

Your email address will not be published.