SORU
15 ŞUBAT 2011, Salı


JavaScript jQuery Otomatik Yükseklik için Animasyon

Merhaba Otomatik yükseklik 200px bir div hareketlendirmek istiyorum. I cant olsa çalışması gibi görünüyor - herkes nasıl biliyor?

İşte kod:

$("div:first").click(function(){
  $("#first").animate({
    height: "auto"
  }, 1000 );
});

CEVAP
15 ŞUBAT 2011, Salı


  1. Geçerli yüksekliği kaydedin:

    var curHeight = $('#first').height();
  2. Geçici olarak geçiş otomatik yükseklik:

    $('#first').css('height', 'auto');
  3. Otomatik yükseklik:

    var autoHeight = $('#first').height();
  4. curHeight ve autoHeight animasyon geçiş:

    $('#first').height(curHeight).animate({height: autoHeight}, 1000);

Ve hep birlikte:

var el = $('#first'),
    curHeight = el.height(),
    autoHeight = el.css('height', 'auto').height();
el.height(curHeight).animate({height: autoHeight}, 1000);

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Call Me Howard

    Call Me Howa

    18 AĞUSTOS 2012
  • David Wills

    David Wills

    31 Aralık 2007
  • jonathepianist

    jonathepiani

    31 Temmuz 2008