如何使用 jQuery 的“slideDown”功能和“向上滑动” jQuery Expander 插件中的效果?

发布于 2024-11-03 01:34:30 字数 2084 浏览 4 评论 0原文

我正在使用 jQuery Expander 插件。我希望它使用 jQuery 的 SlideUp 和 SlideDown 之类的效果,而不是默认的 fadeIn。

有人可以告诉我该怎么做吗?

以下是默认选项:

$.fn.expander.defaults = {
  slicePoint:       100,      // the number of characters at which the contents will be sliced into two parts. 
                              // Note: any tag names in the HTML that appear inside the sliced element before 
                              // the slicePoint will be counted along with the text characters.
  widow:            4,        // a threshold of sorts for whether to initially hide/collapse part of the element's contents. 
                              // If after slicing the contents in two there are fewer words in the second part than 
                              // the value set by widow, we won't bother hiding/collapsing anything.
  expandText:       'read more...',   // text displayed in a link instead of the hidden part of the element. 
                              // clicking this will expand/show the hidden/collapsed text
  expandPrefix:     '… ', // text to come before the expand link                              
  collapseTimer:    0,        // number of milliseconds after text has been expanded at which to collapse the text again
  expandEffect:     'fadeIn',
  expandSpeed:      '',       // speed in milliseconds of the animation effect for expanding the text
  userCollapse:     true,     // allow the user to re-collapse the expanded text.
  userCollapseText: '[collapse expanded text]',  // text to use for the link to re-collapse the text
  userCollapsePrefix: ' ', // text to come before the re-collapse link
  beforeExpand: function($thisEl) {}, // function that is called immediately upon expanding, before the expand occurs
  afterExpand: function($thisEl) {}, // function that is called after the details have finished expanding
  onCollapse: function($thisEl, byUser) {} //function that is called when the details are collapsed (immediately after)

};

I'm using the jQuery Expander plug-in. I would like it to use an effect like jQuery's slideUp and slideDown as opposed to the default, fadeIn.

Can someone tell me how to do this?

Here are the default options:

$.fn.expander.defaults = {
  slicePoint:       100,      // the number of characters at which the contents will be sliced into two parts. 
                              // Note: any tag names in the HTML that appear inside the sliced element before 
                              // the slicePoint will be counted along with the text characters.
  widow:            4,        // a threshold of sorts for whether to initially hide/collapse part of the element's contents. 
                              // If after slicing the contents in two there are fewer words in the second part than 
                              // the value set by widow, we won't bother hiding/collapsing anything.
  expandText:       'read more...',   // text displayed in a link instead of the hidden part of the element. 
                              // clicking this will expand/show the hidden/collapsed text
  expandPrefix:     '… ', // text to come before the expand link                              
  collapseTimer:    0,        // number of milliseconds after text has been expanded at which to collapse the text again
  expandEffect:     'fadeIn',
  expandSpeed:      '',       // speed in milliseconds of the animation effect for expanding the text
  userCollapse:     true,     // allow the user to re-collapse the expanded text.
  userCollapseText: '[collapse expanded text]',  // text to use for the link to re-collapse the text
  userCollapsePrefix: ' ', // text to come before the re-collapse link
  beforeExpand: function($thisEl) {}, // function that is called immediately upon expanding, before the expand occurs
  afterExpand: function($thisEl) {}, // function that is called after the details have finished expanding
  onCollapse: function($thisEl, byUser) {} //function that is called when the details are collapsed (immediately after)

};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぃ双果 2024-11-10 01:34:30

只需使用 $('#yourthing').expander() 默认情况下它使用 SlideDown 和 SlideUp。

http://plugins.learningjquery.com/expander/jquery 查看第 52 行和第 54 行.expander.js — 它没有使用您提到的默认值。

Just use $('#yourthing').expander() by Default it uses slideDown and slideUp.

Check it in lined 52 and 54 at http://plugins.learningjquery.com/expander/jquery.expander.js — It's not using the defaults you mention.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文