Javascript jQueryUISortable,如何检查它是否是最后一个tr并删除类
我有一个tabel,其中有一个表单,它使用sortable来允许拖放排序,它还有上下箭头,可以单击来上下移动行。生成表格时,我在第一行隐藏向上箭头,在最后一行隐藏向下箭头。但是,当拖放或使用箭头上下移动行时,它不会更新上下箭头。我如何解决这个问题:Javascript jQueryUISortable,如何检查它是否是最后一个tr并删除类,javascript,jquery,jquery-ui,jquery-ui-sortable,Javascript,Jquery,Jquery Ui,Jquery Ui Sortable,我有一个tabel,其中有一个表单,它使用sortable来允许拖放排序,它还有上下箭头,可以单击来上下移动行。生成表格时,我在第一行隐藏向上箭头,在最后一行隐藏向下箭头。但是,当拖放或使用箭头上下移动行时,它不会更新上下箭头。我如何解决这个问题: function sortt() { $("#table_or tbody tr:first").find(".moveUp").hide(); $("#table_or tbody tr:last").find(".moveDow
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.
}
});
}
函数sortt(){
$(“#table_或tbody tr:first”).find(“.moveUp”).hide();
$(“#table_或tbody tr:last”).find(“.moveDown”).hide();
$(“#table_或tbody tr”)。每个(function(){
$idx=$(“#table#u或tbody tr”)。索引(this)+1;
$(this.find)(“输入[name$=\u order]”).val($idx);
$(this).children(“td”).eq(2).html(“顺序:”+$idx);
//斑马更新
$(“#table#u或tbody tr:odd”).removeClass().addClass(“zebra2”);
$(“#table#u或tbody tr:偶数”).removeClass().addClass(“zebra1”);
//检查自定义输入是否存在
if($(this).find(“input.custom_opt”).val()!=未定义){
$val=$(this.find(“input.custom_opt”).val();//获取值
$val=$val.split(“|”);//将值字符串拆分为数组
//var cust_dis=$(this.find(“input.cust_dis”).val();
//警报(cust_dis);
$val[6]=$idx;//更新数组中的订单值
$newVal=”“;
//循环遍历数组并重新创建分隔字符串。
对于($i=0;$i请尝试以下代码以查找最后一个tr:
$('#myTableId tr:last').removeClass('className1 ClassName2');
希望这有助于