0

我将 jquery 的动画折叠用于我网站的常见问题解答部分,以保持整洁。

我默认关闭了所有 div,但是如果我使用 URL 查询参数调用 id,有没有办法打开 1 个特定的 div?

我所指的网址是:http://www.carcityofdanbury.com/?cat=02&do=FAQ 意思是如果我有一个指向http://www.carcityofdanbury.com/?cat=02&do=FAQ#id=4页面加载时间的链接,我可以关闭除#4 之外的所有 div 吗?

我搜索了谷歌并找不到这个答案。

谢谢你。

4

2 回答 2

0

Use the method outlined here - http://www.dynamicdrive.com/dynamicindex17/animatedcollapse_suppliment2.htm

For example - http://www.carcityofdanbury.com/?cat=02&do=FAQ&expanddiv=10004

Please note that your element IDs should not start with a number. See HTML & XHTML id attribute question.

I'd also recommend you check out a more up-to-date plugin (dynamic drive, seriously?). Try the Twitter Bootstrap Collapse plugin.

于 2012-04-24T06:04:32.063 回答
0

Stick to all div's that you have attribute data-id = , then on $(document).ready() hide all div's that dont equal to 4

$(document).ready(function(){
    $all_divs = $('#div');
    $all_divs.each(function(){
       if ($(this).attr("data-id") != 4) {
           $(this).hide();
       }
    });
});
于 2012-04-24T06:06:17.850 回答