回答
嗯,我明白了。嘗試
<div class="faque_question_table">
<ul>
<li id="q1"><a class="qli" href="answer.html?#ans1">Create new course</a></li>
<li id="q2"><a class="qli" href="answer.html?#ans2">Set privacy and assign users</a>/li>
<li id="q3"><a class="qli" href="answer.html?#ans3">View course.</a></li>
<li id="q4"><a class="qli" href="answer.html?#ans4">Edit and delete course.</a></li>
<li id="q5"><a class="qli" href="answer.html?#ans5">Add thumbnail representation.</a></li>
</ul>
</div>
<!-- After some code your answer.html-->
<div class="help_sub_content" id='ans1'> Your answer 1</div>
<div class="help_sub_content" id='ans2'> Your answer 1</div>
<div class="help_sub_content" id='ans3'> Your answer 1</div>
<div class="help_sub_content" id='ans4'> Your answer 1</div>
然後腳本
<script>
$(document).ready(function()
{
$(".qli").click(function(){
$('html, body').animate({'scrollTop' : $($(this).attr('href')).offset().top},1000) //Will maybe be $(window) instead of html,body.
return false;
});
});
</script>
@Blessing你可以選擇你正確的答案。無論如何感謝您提出編輯。 – 2013-12-17 06:26:58
我喜歡你的答案。我們來修復兩件事。 1.頁面重定向並滾動到正確的位置,但在一段時間後滾動。可能頁面還沒有完成加載,但我有dom準備好的功能。 2.我們使用類而不是ID,以便可以在所有頁面中引用答案。那麼你怎麼寫這個? 'answer.html?class' – Relm
將id="some-id"
字的容器上,然後把標識上的網址:
http://example.com/faq#some-id
如果你想要一些奇特的滾動發生,並在字褪色,那麼你可以使用像jQuery的。有相當多的插件做花式滾動。淡入淡出可以在不使用插件的情況下完成。
你可以執行該如此輕易mate.Just嘗試下面的腳本,其相當useful.I做了fiddle
適合您purpose.Since你需要一旦點擊鏈接轉到單詞通過identifier word
與# symbol
之後的網址或使用javascript獲得該單詞split
代碼
$('.disclosure').highlight('Test');
$('html, body').animate({
scrollTop: $(".highlight").offset().top
}, 1500);
包含這個腳本
http://johannburkard.de/resources/Johann/jquery.highlight-4.js
小提琴
無需任何外部插件
var src_str = $(".disclosure").html();
var term = "massa";
term = term.replace(/(\s+)/,"(<[^>]+>)*$1(<[^>]+>)*");
var pattern = new RegExp("("+term+")", "i");
src_str = src_str.replace(pattern, "<mark>$1</mark>");
src_str = src_str.replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/,"$1</mark>$2<mark>$4");
$(".disclosure").html(src_str);
$('html, body').animate({
scrollTop: $("mark").offset().top
}, 1500);
小提琴
- 1. 突出顯示頁面後的文本
- 2. 如何在網頁上顯示pdf文件的某些頁面
- 3. Magento 301重定向到某些頁面
- 4. 在導軌中突出顯示當前頁面,僅適用於某些頁面
- 5. 重定向頁面,並自動打開一些收藏
- 6. 重定向到新頁面而不顯示父頁面
- 7. ASP.NET將某些頁面重定向到登錄頁面
- 8. 在某些頁面上未顯示
- 9. 某些頁面上未顯示Wordpress頁面標題
- 10. Highcharts在某些頁面顯示,未顯示在根頁面
- 11. 通過ReguestDispatcher重定向頁面上下文不顯示(白頁)?
- 12. 重新加載頁面,並顯示在頁面的新視圖
- 13. .htaccess規則重定向某些頁面並捕獲所有其他頁面
- 14. 如何在新標籤中打開新的一頁,重定向當前頁面
- 15. 打開彈出窗口後,如何重定向父頁面?
- 16. 突出顯示當前分頁頁面?
- 17. 在頁面上突出顯示頁面鏈接-a:active?
- 18. 如何使用Greasemonkey中的JavaScript重定向某些頁面?
- 19. 如何在asp.net的同一頁面上打開新頁面
- 20. 如何301重定向頁面「向上」頁面
- 21. 某些頁面上的強制方向
- 22. jQuery的點擊打開一個新頁面,並顯示文本(如vouchercodes.co.uk)
- 23. 如何在子頁面的子頁面上突出顯示頂層菜單項?
- 24. 使用頁面動作在某些頁面上顯示Chrome擴展顯示
- 25. 通過彈出頁面重定向並顯示進度
- 26. 顯示頁面重定向時的默認頁面名稱
- 27. 在表單提交上,在新選項卡中打開新頁面並重定向原始頁面
- 28. 重定向某些頁面並拒絕其他人訪問?
- 29. 重定向頁面的一些HTTP和一些頁面到https
- 30. 如何從asp.net中的JS顯示頁面重定向到特定頁面
請張貼一些代碼段 – 2013-12-17 06:00:53