0
我正在使用jQuery ui可選插件。它工作得很好,但是我需要的是獲得所選行和列的長度。我將使用jQuery .attr中的這些數字將選定的單元格與colspan和rowspan一起分組。使用jQuery可選插件獲取選定的行和列
firstCell = $(".ui-selected").first().attr("id");
$("#"+firstCell).attr({"colspan": <dynamic number columns>, "rowspan": <dynamic number rows>});
HTML代碼是用jQuery動態生成的:
$("#div1").empty()
var RH = $("#RH").text();
if(RH) {
$("#div1").css("display", "block");
var html = '<table class="rack" style="border=0; cellspacing=0; cellpadding=1; width: 100%;"><thead><tr></tr></thead><tbody id="selectable">';
html += "<tr><th width='10%'> </th><th width='20%'>Front</th><th width='50%'> Interior</th><th width='20%'>Back</th></tr>";
for (var i = RH; i >= 1; i--) {
html += '<tr>\
<th>'+i+'</th>\
<td id="r'+i+'c1" class="atom state_F r'+i+'c1">\
<div title="Free rackspace"> </div>\
</td>\
<td id="r'+i+'c2" class="atom state_F r'+i+'c2">\
<div title="Free rackspace"> </div>\
</td>\
<td id="r'+i+'c3" class="atom state_F r'+i+'c3">\
<div title="Free rackspace"> </div>\
</td>\
</tr>';
}
html += '</tbody></table>';
$(html).appendTo('#div1');
}
我將如何讓選擇行/列的jQuery UI的選擇返還數量?
請向我們顯示您的HTML代碼。 – vaso123 2014-11-03 15:52:27
你使用jQuery UI可選或其他的東西..? – 2014-11-03 16:02:17
是的,我使用jquery ui selectable。 – Beeelze 2014-11-03 16:03:47