【发布时间】:2014-09-05 00:26:05
【问题描述】:
我的代码示例可以很好地获取选定项目的索引。
<script>
$(function() {
$( "table" ).selectable({
selected: function() {
filter: ".td_to_allow_select",
var result = $( "#result" ).empty();
$( ".ui-selected", this ).each(function() {
var index = $( "#table .td_to_allow_select" ).index( this );
result.append( " #" + ( index + 1 ) );
});
}
});
});
</script>
我的问题是当我尝试选择 div 的 html 时,我尝试的每一种方式都只获得第一个“.td_to_allow_select”的 html。 表格如下:
<table>
<tr>
<td>text</td><td class="td_to_allow_select">3454</td>
</tr>
<tr>
<td>text</td><td class="td_to_allow_select">4534</td>
</tr>
<tr>
<td>text</td><td class="td_to_allow_select">7688</td>
</tr>>
</table>
我尝试的一切都只得到了第一个 TD HTML 3 次“3454 3454 3454”。 我怎样才能获得所选 TD 的 HTML? 或者当鼠标选择它时,有没有人有另一种方法来获取 TD 的 html? 谢谢。
【问题讨论】:
-
不确定你的帖子是否在
selected: function() { filter: ".td_to_allow_select", var result附近
标签: jquery jquery-ui selectable jquery-ui-selectable