jquery multi-select和jQuery quicksearch使用
<html><head><title></title><link href="css/bootstrap.min.css" rel="stylesheet"/><link href="css/multi-select.css" rel="stylesheet"/></head><body><sel
·
<html>
<head>
<title></title>
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link href="css/multi-select.css" rel="stylesheet"/>
</head>
<body>
<select class='searchable' id='' multiple='multiple'>
<option value='elem_1' selected>elem 1</option>
<option value='elem_2'>elem 2</option>
<option value='elem_3'>elem 3</option>
<option value='elem_4' selected>elem 4</option>
<option value='elem_100'>elem 100</option>
</select>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/jquery.multi-select.js"></script>
<script src="js/jquery.quicksearch.js"></script>
<script type="text/javascript">
$('.searchable').multiSelect({
selectableHeader: "<input type='text' class='search-input' autocomplete='off' placeholder='输入1试一试'>",
selectionHeader: "<input type='text' class='search-input' autocomplete='off' placeholder='输入4试一试'>",
afterInit: function(ms) {
var that = this,
$selectableSearch = that.$selectableUl.prev(),
$selectionSearch = that.$selectionUl.prev(),
selectableSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selectable:not(.ms-selected)',
selectionSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selection.ms-selected';
that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
.on('keydown',
function(e) {
if (e.which === 40) {
that.$selectableUl.focus();
return false;
}
});
that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
.on('keydown',
function(e) {
if (e.which == 40) {
that.$selectionUl.focus();
return false;
}
});
},
afterSelect: function() {
this.qs1.cache();
this.qs2.cache();
alert($('.searchable').val());
},
afterDeselect: function() {
this.qs1.cache();
this.qs2.cache();
alert($('.searchable').val());
}
});
</script>
</body>
</html>
如图


魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)