jQuery WEUI select的使用
1.官网样式:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f699ba6d5ecd17b02f6cc3917b02cc58.png)
html样式
<div class="weui-cell">
<div class="weui-cell__hd"><label class="weui-label">联系人</label></div>
<div class="weui-cell__bd">
<input class="weui-input" type="text" id='job' placeholder="请输入你的联系人">
</div>
</div>
</div>
JavaScript
$("#job").select({
title: "选择职业",
items: ["法官", "医生", "猎人", "学生", "记者", "其他"]
});
2.数据从数据库获取:
JavaScript
$.ajax({
url: '/demo/job',
datatype: "json",
success: function (data) {
if (data) {
var datalist = new Array;
for (var i = 0; i < data.length; i++) {
var info = {"title": data[i].name, "value": data[i].id};
datalist.push(info);
}
console.log(datalist);
$("#job").select({
title: "职业",
multi: false,
items: datalist,
beforeClose: function (values, titles) {
return true;
}
});
}
}
});