2012-04-22 193 views
0

當我有了很多內容在裏面,只是在div垂直滾動一個div滾動DIV的底部。HTML - 鏈接被點擊

我有需要可以輕鬆搞定的DIV底部的東西。雖然我不能將它移出div。

有一個鏈接,我可以使用,或者一些javasript,使其滾動到div的底部單擊鏈接時?

回答

2

你不需要任何JavaScript這一點。 HTML有內置的功能。您可以使用name anchors跳轉到頁面的某些部分,而無需重新加載文檔。

<div> 
    <p> 
     Lots of content 
    </p> 
    <a href="#importantplace">click this link to get to the bottom of the div</a> 
    <p> 
     Lots of content 
    </p> 
    <p id="importantpplace"> 
     Important content 
    </p> 
</div> 
+1

提示!爲別人讀約翰回答一個ID屬性可以與幾乎所有的元素被使用,所以你可以使用ID而不是名稱 – david 2012-04-22 16:24:41

+0

我也想使用'id',而不是'name'建議,絕對跳過空'了'元素。 – powerbuoy 2012-04-22 16:26:30

+0

我已經更新了我的答案。感謝您的建議。 – 2012-04-22 16:29:58