layui之动态添加下拉菜单

转:https://blog.csdn.net/Code_shadow/article/details/80431937

(不显示一定要先把select标签写上,不能标签也动态生成,那样会不显示 )

//html
<select id="selectID"></select>
//js
$.ajax({
    url:'departmentAction_findAllDepartment.action',
    dataType:'json',
    type:'post',
    success:function(data){

        $.each(data,function(index,item){
            $('#selectID').append(new Option(item.name,item.id));//往下拉菜单里添加元素
        })

        form.render();//菜单渲染 把内容加载进去
    }
})


猜你喜欢

转载自blog.csdn.net/wybshyy/article/details/80974455
今日推荐