用于前端,只需要列表初始值(默认值),列表值,和选择事件就可以轻松绑定下拉框。绑定选中拓展事件可实现选中数据后执行的操作。简单易用。
ComboBox()Contents
- ComboBox()
html代码
<head>
<title></title>
<link href="/_css/common.css" rel="stylesheet" type="text/css" />
<script src="/_js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="/_js/Valid.js" type="text/javascript"></script>
<script src="download.js" type="text/javascript"></script>
</head>
<body>
<b class="com_table"></b>
</body>
init()
init
示例:
$(document).ready(function () {
var grade = [{ id: 0, name: "默认值" }, { id: 1, name: "第二个" }, { id: 2, name: "第三个"}];
var combobox = new ComboBox();
combobox.tag = $('.com_table');
combobox.data_default = grade[0];
combobox.data_list = grade;
combobox.init();
})
var grade = [{ id: 0, name: "默认值" }, { id: 1, name: "第二个" }, { id: 2, name: "第三个"}];
var combobox = new ComboBox();
combobox.tag = $('.com_table');
combobox.data_default = grade[0];
combobox.data_list = grade;
combobox.init();
})
展示效果:
selectedIndexExpand(tag,index)
selectedIndexExpand
参数:
- tag:下拉框对象
- index:选择的索引值
示例:
$(document).ready(function () {
var grade = [{ id: 0, name: "默认值" }, { id: 1, name: "第二个" }, { id: 2, name: "第三个"}];
var combobox = new ComboBox();
combobox.tag = $('.com_table');
combobox.data_default = grade[0];
combobox.data_list = grade;
//选择拓展事件
combobox.selectedIndexExpand = function (tag, index) {
alert("您选择了第" + index + "个");
}
combobox.init();
})
var grade = [{ id: 0, name: "默认值" }, { id: 1, name: "第二个" }, { id: 2, name: "第三个"}];
var combobox = new ComboBox();
combobox.tag = $('.com_table');
combobox.data_default = grade[0];
combobox.data_list = grade;
//选择拓展事件
combobox.selectedIndexExpand = function (tag, index) {
alert("您选择了第" + index + "个");
}
combobox.init();
})
展示效果: