如何使手风琴标题上仅可单击特定文本 - jquery?
我向手风琴标题添加了删除和编辑链接,但这些链接不起作用,因为每次我单击它们时手风琴都会打开。以及关于我该如何做的建议?请注意,我正在做嵌套手风琴。 这就是我在 js 上定义它的方式:
$("#acc2").accordion({ alwaysOpen: false,active: false,autoheight: false,
header: 'h3.ui-accordion2-header',clearStyle: true,
event: 'click' });
在 html 上我有这样的定义:
<div class="ui-accordion2-group">
<h3 class="ui-accordion2-header">
<table border=0 width=100% class= 'DarkGray12' >
<tr>
<td>
<a href="javascript:toggel_new_activity('1');">Section Title</a>
</td>
<td align='right'>
<table border=0>
<tr>
<td>
<a href="javascript:toggel_new_activity('1');">New Activity</a>
</td>
<td>
<a href='#'>Edit</a>
</td>
<td>
<a href='#'>Delete</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</h3>
</div>
I added delete and edit link to the accordion header, yet those links are not working since every time i click on them the accordion open. And advice on how can I do it? Note that I'm doing nested accordion.
this is how i defined it on js:
$("#acc2").accordion({ alwaysOpen: false,active: false,autoheight: false,
header: 'h3.ui-accordion2-header',clearStyle: true,
event: 'click' });
and on html I have it like this:
<div class="ui-accordion2-group">
<h3 class="ui-accordion2-header">
<table border=0 width=100% class= 'DarkGray12' >
<tr>
<td>
<a href="javascript:toggel_new_activity('1');">Section Title</a>
</td>
<td align='right'>
<table border=0>
<tr>
<td>
<a href="javascript:toggel_new_activity('1');">New Activity</a>
</td>
<td>
<a href='#'>Edit</a>
</td>
<td>
<a href='#'>Delete</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</h3>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,删除 h3 中的那些表。将 div 与 css 结合使用:
其次,无需添加内联事件,请在顶部进行操作:
ev.preventDefault() 可以防止单击“a”标签时发生的正常情况发生。
ev.stopPropaggation() 阻止点击事件到达相应的位置并切换该部分的状态。
剩下的只是找出当前部分的 id,并根据单击的链接进行正确的函数调用。
First thing, get rid of those tables in the h3's. Use divs with css:
Second, No need to add events inline do it up at the top:
ev.preventDefault() prevents the normal things that happen when you click an "a" tag from happening.
ev.stopPropaggation() prevents the click event from getting to the according and toggling the status of the section
The rest just figures out the id for the current section and makes the correct function call based on what link was clicked.