通过ajax获取easydropdown数据

来源:互联网 发布:鲜活的数据 pdf 编辑:程序博客网 时间:2024/05/17 23:02

使用easydropdown固定需要三个文件:easydropdown.css、jquery.easydropdown.js、jquery-2.0.3.min.js

html 中 使用样式(class="dropdown"):

<select name="tm_type_select" id="tm_type_select" class="dropdown" value="" onchange="selectTmType()">   <option value="" >题目类型</option></select>


js通过ajax获取数据后,加入下拉框中,再调用easydropdown事件:

success : function(result) {   var html = "";   for(var i in result ){      html += "<option value='" + i + "'>" + result[i] + "</option>"   }   $("#tm_type_select").append(html);   $("#tm_type_select").easyDropDown("destroy"); // 必不可少,因为前端样式已经变成ul和li了,所以必须先销毁一遍.   $("#tm_type_select").easyDropDown();},