jQuery 手风琴不适合我
我正在寻找使用 jQuery 手风琴的一些帮助。
基本上,我的元素不是开箱即用的标准 h3 和 p 标签。
我的 jQuery 如下
<script>
jQuery(document).ready(function() {
jQuery("#contentHolder").accordion({
header: '.clicker'
});
});
</script>
,我使用的 HTML 如下:
<div id="contentHolder">
<div id="recipe">
<img src="style/img/rec-image.jpg"></img>
<p><span style="color: #5C971C; font-weight: bold;">Stuffs M</span><br />stuff goes here</p>
<p><a class="clicker" href="#"><img src="style/img/details-btn.jpg"></img></a></p>
<div class="ingredients" style="margin-top: 136px;">
<p style="width: 420px;"><span style="color: #5C971C; font-weight: bold;">Ingredients</span><br />2L white vinegar<br />2 cups water</p>
</div>
</div>
<div id="recipe">
<img src="style/img/rec-image.jpg"></img>
<p><span style="color: #5C971C; font-weight: bold;">Stuffs M</span><br />stuff goes here</p>
<p><a class="clicker" href="#"><img src="style/img/details-btn.jpg"></img></a></p>
<div class="ingredients" style="margin-top: 136px;">
<p style="width: 420px;"><span style="color: #5C971C; font-weight: bold;">Ingredients</span><br />2L white vinegar<br />2 cups water</p>
</div>
</div>
</div>
我希望它如何工作,就是当有人单击 .clicker href 时,我希望 div“成分”上下滑动。
我希望有人能提供帮助:)
干杯,
Im looking for a bit of help using the jQuery accordion.
Basically, i have elements that arent the standard h3 and p tags that it requires out of the box.
The jQuery i have is as follows
<script>
jQuery(document).ready(function() {
jQuery("#contentHolder").accordion({
header: '.clicker'
});
});
</script>
and the HTML that im using is as follows:
<div id="contentHolder">
<div id="recipe">
<img src="style/img/rec-image.jpg"></img>
<p><span style="color: #5C971C; font-weight: bold;">Stuffs M</span><br />stuff goes here</p>
<p><a class="clicker" href="#"><img src="style/img/details-btn.jpg"></img></a></p>
<div class="ingredients" style="margin-top: 136px;">
<p style="width: 420px;"><span style="color: #5C971C; font-weight: bold;">Ingredients</span><br />2L white vinegar<br />2 cups water</p>
</div>
</div>
<div id="recipe">
<img src="style/img/rec-image.jpg"></img>
<p><span style="color: #5C971C; font-weight: bold;">Stuffs M</span><br />stuff goes here</p>
<p><a class="clicker" href="#"><img src="style/img/details-btn.jpg"></img></a></p>
<div class="ingredients" style="margin-top: 136px;">
<p style="width: 420px;"><span style="color: #5C971C; font-weight: bold;">Ingredients</span><br />2L white vinegar<br />2 cups water</p>
</div>
</div>
</div>
How i want it to work, is when someone clicks on the .clicker href i want the div "ingredients" to slide up and down.
Im hoping someone can help :)
Cheers,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 jQuery UI Accordian 文档
您的“点击器”位于 p 元素内部
也许将“点击器”放在 p 元素上?或者去掉 p 元素。只需确保您尝试显示的 div 是 DOM 中的“下一个”元素即可。
According to jQuery UI Accordian docs
Your "clicker" is inside of a p-element
Maybe put the "clicker" on the p-element? Or get rid of the p-element. Just make sure the div you are trying to show is the "next" element in the DOM.
手风琴需要以下结构:
另请参阅在此 jsfiddle 中工作的示例。
===更新===
虽然我忘了说这不一定是'div'需要执行的操作,但是对于每个块元素:
另请参阅我更新的jsfiddle.
The accordion needs following structure:
Also see your example working in this jsfiddle.
=== UPDATE ===
Although I had forgotten to say that this is not necessarily 'div' s need to act, but to each block element:
Also see my updated jsfiddle.