我想知道您是否能给我一些关于如何做到这一点的想法。我们想要做的是直接链接到我们的常见问题解答页面中的问题。目前我们的常见问题解答问题正在通过 jQuery 隐藏,如下所示:
$(document).ready(function() {
$('.answer').each(function() {
$(this).css("display", "none");
});
$('.question').click(function() {
$(this).next('.answer').slideToggle("fast")
return false;
});
});
我们希望链接到一个特定问题,但对该问题进行了扩展。
最佳答案
我会将 URL 中的问题部分作为哈希传递,例如url/faq.html#question1
然后使用一些 JavaScript,您可以检查哈希值,然后将用户滚动到该部分并切换幻灯片。
$(function(){
if(window.location.hash) {
// Fragment exists
// use hash value to match an attribute in the question.
// scroll to Q/A and toggle.
}
});
关于jquery - 如何直接链接到扩展的常见问题解答选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8188833/