如何解决jQuery UI可排序,如何检查其最后一个tr并删除类
|| 我有一个表格,其中有一个表格,该表格使用可排序以允许拖放排序,它还具有可以单击以上下移动行的上下箭头。生成表格后,我在第一行隐藏了向上箭头,在最后一行隐藏了向下箭头。但是,当拖放或使用箭头上下移动行时,它不会更新上下箭头。我该如何解决:function sortt() {
$(\"#table_or tbody tr:first\").find(\".moveUp\").hide();
$(\"#table_or tbody tr:last\").find(\".moveDown\").hide();
$(\"#table_or tbody tr\").each(function(){
$idx = $(\"#table_or tbody tr\").index(this)+1;
$(this).find(\"input[name$=_order]\").val($idx);
$(this).children(\"td\").eq(2).html(\"Order: \"+$idx);
//updates zebra
$(\"#table_or tbody tr:odd\").removeClass().addClass(\"zebra2\");
$(\"#table_or tbody tr:even\").removeClass().addClass(\"zebra1\");
//Check if the custom input exists
if($(this).find(\"input.custom_opt\").val()!=undefined){
$val = $(this).find(\"input.custom_opt\").val(); //get the value
$val = $val.split(\"|\"); //split the value string into an array
// var cust_dis = $(this).find(\"input.cust_dis\").val();
// alert(cust_dis);
$val[6] = $idx; //Update the order value within the array
$newVal = \"\";
//Loop through the array and recreate delimited string.
for( $i=0; $i<$val.length; $i++ ){
if($i!=0){ $newVal = $newVal+\"|\"; }
$newVal = $newVal+$val[$i];
}
$(this).find(\"input.custom_opt\").val($newVal); //Give the custom input its updated value.
}
});
}
解决方法
尝试以下代码找到最后一个tr:
$(\'#myTableId tr:last\').removeClass(\'className1 ClassName2\');
希望这可以帮助...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。