开发者

Jquery expand from external link

I am trying to make it so tha开发者_StackOverflow中文版t when a user clicks on a link from one page, it goes to another page that has a simple jquery collapsed text and expands (un-collapses) the text. My attempt is with the code below:

$(function() {
  var elem = $('#expand-4' + location.hash); 
  $('#expand-4-text').slideToggle('fast', function() {
     // Animation complete.
  });
  $('#expand-4').toggleClass('expand-4-expanded');
});

It does not work though. Can someone tell me why?


You're calling "slideToggle()" on a part of the page that's already visible, so jQuery hides it for you — that's what "slideToggle()" is supposed to do. You can make it show the text instead by simply hiding it first:

$('#expand-4-text').hide().slideToggle('fast');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜