SORU
25 Mayıs 2010, Salı


Nasıl belirli bir öğe jQuery kullanarak ilerleyin.

Dikey kaydırma çubuğu ile büyük bir tablo var. Bu tablo, jQuery/Javascript kullanarak belirli bir satıra kaydırmak istiyorum.

Yerleşik yöntemleri bunu yapmak için var mı?

Here is a little example to play with.

div {
    width: 100px;
    height: 70px;
    border: 1px solid blue;
    overflow: auto;
}
<div>
    <table id="my_table">
        <tr id='row_1'><td>1</td></tr>
        <tr id='row_2'><td>2</td></tr>
        <tr id='row_3'><td>3</td></tr>
        <tr id='row_4'><td>4</td></tr>
        <tr id='row_5'><td>5</td></tr>
        <tr id='row_6'><td>6</td></tr>
        <tr id='row_7'><td>7</td></tr>
        <tr id='row_8'><td>8</td></tr>
        <tr id='row_9'><td>9</td></tr>
    </table>
</div>

CEVAP
25 Mayıs 2010, Salı


Ölü basit.Hayır eklentileri gerekli.

var container = $('div'),
    scrollTo = $('#row_8');

container.scrollTop(
    scrollTo.offset().top - container.offset().top   container.scrollTop()
);

// Or you can animate the scrolling:
container.animate({
    scrollTop: scrollTo.offset().top - container.offset().top   container.scrollTop()
});​

Burada working example.

Documentation for scrollTop.

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • B4ROK

    B4ROK

    1 EKİM 2008
  • bcbauer

    bcbauer

    7 ŞUBAT 2007
  • EmperorTigerstar

    EmperorTiger

    14 EYLÜL 2009