Layui框架中div里元素上下移动

434 阅读1分钟

欢迎大家加入qq群一起讨论学习: layui交流群:795477608 web前端交流群:799260442

var active = {

    //单选/多选 上移元素 量表选项 ,

        upDoms:function(othis){ 
         //判断是否到顶 
            if($(this).parents('.addNewoptions').index()==0){ 
               layer.alert("已经是第一个") 
                return; 
            } 
            $(othis).parents('.addNewoptions').prev().before($(othis).parents('.addNewoptions'));
         } 
         //单选/多选 下移元素 量表选项 
         ,downDoms:function(othis){ 
           //判断是否到底
           if($(this).parents('.addNewoptions').index()==$('.addNewoptions').length - 1){ 
                layer.alert("已经是最后一个") 
                return; 
             } 
             $(this).parents('.addNewoptions').next().after($(this).parents('.addNewoptions')); 
        } 
    }

以下是方法调用: