如何直接链接到常见问题解答选项 [英] How to link directly to an FAQ option expanded
本文介绍了如何直接链接到常见问题解答选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道您是否可以给我一些有关如何做到这一点的想法.我们想要做的是直接链接到常见问题"页面中的问题.目前,我们的FAQ问题正像这样通过jQuery隐藏:
I was wondering if you could give me some ideas on how I can do this. What we are looking to do is link directly to a question in our FAQ page. Currently our FAQ questions are being hidden via jQuery like so:
$(document).ready(function() {
$('.answer').each(function() {
$(this).css("display", "none");
});
$('.question').click(function() {
$(this).next('.answer').slideToggle("fast")
return false;
});
});
我们想链接到一个特定的问题,但要扩大该问题.
We would like to link to a specific question but have that question expanded.
推荐答案
我会将URL中的quetsion部分作为哈希值传递,例如url/faq.html#question1
I would pass the quetsion section in the URL as a hash, e.g. url/faq.html#question1
然后使用一些JavaScript,您可以检查哈希值,然后将用户滚动到相应部分并切换幻灯片.
Then using some javascript, you could check for the hash, then scroll the user to the section and toggle the slide.
$(function(){
if(window.location.hash) {
// Fragment exists
// use hash value to match an attribute in the question.
// scroll to Q/A and toggle.
}
});
这篇关于如何直接链接到常见问题解答选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文