开发者

Expand a jquery collapse from an external link

Is it possible to expand a jquery collapse by clicking on an external link? For example: on the home page we have a link to another page and when the user clic开发者_运维百科ks on the link from the home page, we want it to go the internal page and expand the collapsed jquery section that it corresponds to.


This isn't possible directly, however you can pass the required information via the URL hash and put the expand code in the target page:

Home page:

<a href="internal.html#section1">Go to section 1</a>

Internal page:

$(function() {
  var elem = $('#' + location.hash);
  // expand elem here
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜