Search Results

Search found 1 results on 1 pages for 'kevn'.

Page 1/1 | 1 

  • How do I stop a jquery animation based on CSS values?

    - by kevn
    So, I have two divs: #div1 and #div2. I want '#div2' to disappear when '#div1' has the CSS value: top = 0px. Here is the CSS: #div1 { top: 0px; } #div2 { display: block; } if ( $('#div1').css('top') == '0px' ) { $("#div2").hide(); } else { $("div2").fadeIn(); } $("div2").click(function(){ $("#div1").animate({top:"+=315px"}, "slow"); }); The problem I am running into is that I'm changing that CSS value (for #div1) via Javascript and for this reason, my js doesn't acknowledge the change and doesn't make the div disappear (I think). Is there any way to make #div2 disappear when #div1's CSS property top = 0 and reappear whenever it is changed? Or is there a better way to implement this?

    Read the article

1