tags:

views:

57

answers:

1

Hi, I've problem with animation, I want to animate div when I click on him, but don't want to animate when I click on the other stuff inside that div.

Here is me test site: http://kni.prz.rzeszow.pl/~plum/portfolio/index.html

Kontakt div is that what i'm looking for but when I click on textareas div is animated. So that is the problem. Thx & regars.

Code on my site, but that is fragment of animate div id="kontakt":

$(function(){
$("#kontakt").click(function(){
    //zabezpieczenie przed animowaniem wielu div'ów na raz
            if ($('div').is(':animated')) {
        return;
    }
            //główna animacja odpowiedzialna za powiększanie i zmniejszanie div'a
    if (kontakt == 0) {
        kontakt = 1;
        $(this).fadeTo(500, 0.33).delay(500).fadeTo(500, 1);
        $(this).animate({
            left: '+=205',
            top: '-=205'
        }, 1000, function(){
            $(this).animate({
                width: 400,
                height: 400,
                left: '-=205'
            }, 1000, function(){
                $.get('kontakt.html', function(data){
                    $('#kontakt').html(data);
                });
            });
        });
    }
    else 
        if (kontakt == 1) {
            kontakt = 0;
            $(this).html('<a href="#">Kontakt</a>');
            $(this).animate({
                left: '+=205',
                width: 195,
                height: 195
            }, 1000, function(){
                $(this).animate({
                    left: '-=205',
                    top: '+=205'
                }, 1000);
            });
        }
});});

That doesn't help me:

$(':text, textarea').click(function(e){
e.stopPropagation();
alert('to dziala');
return true;});
+4  A: 

You can change your #kontakt handler slightly to check the target of the event, like this:

$("#kontakt").click(function(e) {
    if(!$(e.target).is('div, a')) return;

Using .is() we're checking whether you clicked on the <div> directly, or the <a> (the mail icon). If neither of these are true, we jump out out and don't do anything else :)

Nick Craver