admin管理员组文章数量:1336193
I want to use jQuery Selectable to select rows from a table. The problem is that jQuery seems to hijack all click events so that I can't use anything clickable (links in my case) inside the table.
Html:
<table class="sel-table">
<thead>
<th>col1</th>
<th>col2</th>
<th>col3</th>
</thead>
<tbody>
<tr>
<td>
<a href="">click me! a1</a>
</td>
<td>a2</td>
<td>a3</td>
</tr>
<tr>
<td>b1</td>
<td>b2</td>
<td>b3</td>
</tr>
<tr>
<td>c1</td>
<td>c2</td>
<td>c3</td>
</tr>
</tbody>
</table>
CSS:
.ui-selectable>.ui-selected
{
background-color: #a6c9e2;
}
Javascript:
$(".sel-table>tbody").selectable({filter: 'tr'});
JSFiddle: /
When you click the link, nothing happens, selectable processes the event instead. However, the middle button (open in new tab) works perfectly. What's preventing the default action on link and how can I fix it?
I want to use jQuery Selectable to select rows from a table. The problem is that jQuery seems to hijack all click events so that I can't use anything clickable (links in my case) inside the table.
Html:
<table class="sel-table">
<thead>
<th>col1</th>
<th>col2</th>
<th>col3</th>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.google.">click me! a1</a>
</td>
<td>a2</td>
<td>a3</td>
</tr>
<tr>
<td>b1</td>
<td>b2</td>
<td>b3</td>
</tr>
<tr>
<td>c1</td>
<td>c2</td>
<td>c3</td>
</tr>
</tbody>
</table>
CSS:
.ui-selectable>.ui-selected
{
background-color: #a6c9e2;
}
Javascript:
$(".sel-table>tbody").selectable({filter: 'tr'});
JSFiddle: http://jsfiddle/qt67rf12/
When you click the link, nothing happens, selectable processes the event instead. However, the middle button (open in new tab) works perfectly. What's preventing the default action on link and how can I fix it?
Share asked Aug 31, 2014 at 18:59 Jan HadáčekJan Hadáček 1874 silver badges8 bronze badges 1- See my solution here: stackoverflow./questions/25419263/… – Gjermund B. Dahl Commented Oct 18, 2017 at 21:03
1 Answer
Reset to default 6You can use the cancel
option
$(".sel-table>tbody").selectable({
filter: 'tr',
cancel: 'a'
});
Updated fiddle.
Here is the documentation
本文标签: javascriptUsing jQuery selectable on table rowslinks in table not workingStack Overflow
版权声明:本文标题:javascript - Using jQuery selectable on table rows, links in table not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742402293a2468126.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论