努力解决这个 jQuery div 折叠/展开问题

发布于 2024-09-08 01:22:03 字数 327 浏览 1 评论 0原文

我使用此示例作为基础 http://simon.tpdserver2.co.uk /jquery/divgrowdemo.htm,我试图修改它,以便 jQuery 插件生成一个 html a-href,允许用户切换展开/折叠(在本例中,它的形式为“ + 显示更多”和“- 显示更少”链接),我可以使用实际 div 本身内的链接。举个例子,每个 div 都有“Michael Jordan”作为标题,我想将其设为可切换展开和折叠的可点击项目。我该怎么做呢?

I'm using this example as a basis http://simon.tpdserver2.co.uk/jquery/divgrowdemo.htm, I'm trying to modify it so that instead the jQuery plugin generating an html a-href that allows the user to toggle the expand/collapse (in this case it's in the form of "+ Show More" and "- Show Less" links), that I can use a link that's within the actual div itself. So as an example, each of the divs has "Michael Jordan" as the header, I'd like to make that the clickable item that toggles the expansion and collapse. How would I go about doing that?

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

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

发布评论

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

评论(2

哽咽笑 2024-09-15 01:22:03

该页面上使用的插件添加了链接项然后单击标有“more-block”类的 div 的事件处理程序。您必须修改该插件。您需要将其更改为“链接”标题文本(即在该示例中的相应 div 中找到“h2”元素,并添加“单击”处理程序 - 为了更轻松地设置样式,您可能想要更改内容链接或按钮元素)并为您添加的新链接添加点击处理程序。

The plugin used on that page adds the link item and click event handler to the divs marked with the 'more-block' class. You would have to modify the plugin. You would need to change it to 'linkify' the header text (i.e. find 'h2' elements in the appropriate divs, in that exmaple, and add a 'click' hander - to make it easier to style you might want to change the contents to a link or button element) and add click handlers for the new links you've added.

爱*していゐ 2024-09-15 01:22:03

您将必须修改代码,以便将它们添加到标题周围,而不是插入新标签。因为这是别人的脚本,它不是为您想做的事情而制作的。我建议你自己重新创建这个东西,并将其缩小到基础。首先将高度更改为某个固定高度并在末尾添加 ...。然后向标题添加一个 onclick 事件,以删除固定高度和...然后,找到一些有关执行滑动效果的教程。

You are going to have to modify the code so that instead of inserting the new tags it adds them around the header. Because this is someone else script and it was not made for what you want to do. I would suggest just recreating the thing your self and scaling it down to the basics. First change the height to some fixed height and add the ... at the end. Then add an onclick event to the title that removes the fixed height and the ... Then after you have that find some tutorial on doing the sliding effect.

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