有没有更简单的方法来使用 jQuery 手风琴?
我一直在努力解决我一直试图创建的功能。 这里的想法是,用户看到小缩略图+标题,以及发布者信息。然后,他们可以单击标题展开到文章,或单击“评论”链接直接展开到对文章的评论。或者,如果他们愿意,可以通过单击标题(展开到文章)来查看评论,然后单击“查看评论”(展开到评论)。最后,一个模块化但灵活且功能齐全的打开/关闭系统可以查看最新新闻。
这是我一直在做的事情:(我把所有代码放在一个地方,这样任何人都可以更轻松地查看)http://notedls.com/pointtest.html
这就是我正在拍摄的目标,但它离我想要的还很远;( 它使用 jQuery 1.6 插件,1.8 版本已经发布,但我还远远不是这方面的大师或专家,而且我不认为我可以从头开始构建。我已经编辑了这个插件,让它像这样工作,但是正如你所看到的,作者和评论开始让粉丝们大吃一惊;;这是因为代码正在调用标头的“A TAG”;这是标题。
有谁知道有什么更简单的方法来实现我的设想或者可能的方法来修复当前的代码?此时我非常绝望;;
I've been struggling with a feature I've been trying to create for sometime.
The idea here is that the user sees the little thumbnail + headline, as well as the Posted By information. They can then click on the headline to expand to the article or click on the "Comments" link to expand directly to the comments made on the article. Or, if they want they can view comments by clicking on the headline(to expand to the article), then click on View Comments (to expand to the comments). In the end, a modular yet flexible and functional open/close system to view latest news.
Here is what I've been working on: (I put all my code in one place so its easier on whomever may look at this to view) http://notedls.com/pointtest.html
This is what I'm shooting for, but it's far from what I want ;(
It's using the jQuery 1.6 plugin, which 1.8 is out but I'm far from being a master or expert at this and I don't think I could build from the ground up. I've already edited this plugin to get it to work like this, but as you can see, the AUTHOR and Comments start making shit hit the fan ;; It's because the code is calling the "A TAG" for the header; which is the headline.
Does anyone know any easier way to achieve what I'm envisioning or possible a way to fix this current code? I'm pretty desperate at this point ;;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西:?
http://jsbin.com/elawu
这是一把手风琴。每个“第一个元素”或标题都是一个 div。该标题中包含文章标题、作者和列出该文章评论数量的可点击范围。
每个“第二个元素”,或者手风琴的内容部分,也是一个 div。该 div 中有一个文章内容 div 和评论 div。在评论 div 中,有一个评论标题(同样可点击)和另一个内容 div。层次结构如下所示:
当页面启动时,所有评论内容 div 都会通过
$('div.comments div').hide();
隐藏,同时手风琴也会被设置,并且手风琴 < code>onaccordionchange 和onaccordionchangestart
事件被绑定。最后,为评论链接注册一个点击事件。如果单击标题上的任意位置,则会弹出关联的手风琴内容选项卡。如果您单击标题中的评论链接,它将打开手风琴,并打开内容 div 中的评论 div。
每当打开手风琴选项卡时,标题中的评论链接就会被隐藏。每当手风琴选项卡关闭时,标题中的评论链接都会显示。
单击手风琴内容 div 中的评论链接可切换实际评论。
Something like this:?
http://jsbin.com/elawu
It's an accordion. Each "first element", or header, is a div. Within that header is an article headline, an author, and a clickable span listing the number of comments for that article.
Each "second element", or content portion of the accordion, is also a div. Within that div there is an article content div, and comments div. Within the comments div there is a comment header, again clickable, and another content div. The hierarchy looks like this:
When the page starts all the comment content divs get hidden via
$('div.comments div').hide();
Also the accordion gets set up, and the accordiononaccordionchange
andonaccordionchangestart
events get bound. Finally, a click event is registered for the Comments links.If you click anywhere on the header, it pops open the associated accordion content tab. If you click on the comments link in the header, it opens the accordion, and opens the comments div within the content div.
Any time an accordion tab gets opened, the comments link in the header gets hidden. Any time an accordion tab closes, the comments link in the header gets shown.
Clicking on the comments link within the accordion content div, toggles the actual comments.
哦,我觉得我明白了
并使用隐藏的 css 类
oh, i feel i get it
and use hidden css class